Skip to content

Commit 1305258

Browse files
committed
Updated tests to native php attributes from doc-comment metadata
1 parent beb9b27 commit 1305258

9 files changed

+68
-59
lines changed

tests/Integration/TwilioProviderTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
use NotificationChannels\Twilio\TwilioChannel;
1010
use NotificationChannels\Twilio\TwilioConfig;
1111
use NotificationChannels\Twilio\TwilioProvider;
12+
use PHPUnit\Framework\Attributes\Test;
1213
use Twilio\Rest\Client;
1314

1415
class TwilioProviderTest extends IntegrationTestCase
1516
{
16-
/** @test */
17+
#[Test]
1718
public function it_cannot_create_the_application_without_config()
1819
{
1920
$this->expectException(InvalidConfigException::class);
2021

2122
$this->app->get(TwilioChannel::class);
2223
}
2324

24-
/** @test */
25+
#[Test]
2526
public function it_cannot_create_the_application_without_sid()
2627
{
2728
$this->app['config']->set('twilio-notification-channel.username', 'test');
@@ -31,7 +32,7 @@ public function it_cannot_create_the_application_without_sid()
3132
$this->app->get(TwilioChannel::class);
3233
}
3334

34-
/** @test */
35+
#[Test]
3536
public function it_can_create_the_application_with_sid()
3637
{
3738
$this->app['config']->set('twilio-notification-channel.username', 'test');
@@ -41,7 +42,7 @@ public function it_can_create_the_application_with_sid()
4142
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
4243
}
4344

44-
/** @test */
45+
#[Test]
4546
public function it_can_create_the_application_with_token_auth()
4647
{
4748
$this->app['config']->set('twilio-notification-channel.auth_token', 'token');
@@ -50,7 +51,7 @@ public function it_can_create_the_application_with_token_auth()
5051
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
5152
}
5253

53-
/** @test */
54+
#[Test]
5455
public function it_provides_three_classes()
5556
{
5657
$provides = (new TwilioProvider($this->app))->provides();

tests/Unit/IntegrationTest.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use NotificationChannels\Twilio\TwilioChannel;
1414
use NotificationChannels\Twilio\TwilioConfig;
1515
use NotificationChannels\Twilio\TwilioSmsMessage;
16+
use PHPUnit\Framework\Attributes\Test;
1617
use Twilio\Rest\Api\V2010\Account\CallInstance;
1718
use Twilio\Rest\Api\V2010\Account\CallList;
1819
use Twilio\Rest\Api\V2010\Account\MessageInstance;
@@ -42,7 +43,7 @@ protected function setUp(): void
4243
$this->notification = Mockery::mock(Notification::class);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_can_send_a_sms_message()
4748
{
4849
$message = TwilioSmsMessage::create('Message text');
@@ -62,7 +63,7 @@ public function it_can_send_a_sms_message()
6263
$channel->send(new NotifiableWithAttribute, $this->notification);
6364
}
6465

65-
/** @test */
66+
#[Test]
6667
public function it_can_send_a_sms_message_using_service()
6768
{
6869
$message = TwilioSmsMessage::create('Message text');
@@ -84,7 +85,7 @@ public function it_can_send_a_sms_message_using_service()
8485
$channel->send(new NotifiableWithAttribute, $this->notification);
8586
}
8687

87-
/** @test */
88+
#[Test]
8889
public function it_can_send_a_sms_message_using_url_shortener()
8990
{
9091
$message = TwilioSmsMessage::create('Message text');
@@ -106,7 +107,7 @@ public function it_can_send_a_sms_message_using_url_shortener()
106107
$channel->send(new NotifiableWithAttribute, $this->notification);
107108
}
108109

109-
/** @test */
110+
#[Test]
110111
public function it_can_send_a_sms_message_using_alphanumeric_sender()
111112
{
112113
$message = TwilioSmsMessage::create('Message text');
@@ -127,7 +128,7 @@ public function it_can_send_a_sms_message_using_alphanumeric_sender()
127128
$channel->send(new NotifiableWithAlphanumericSender, $this->notification);
128129
}
129130

130-
/** @test */
131+
#[Test]
131132
public function it_can_make_a_call()
132133
{
133134
$message = TwilioCallMessage::create('http://example.com');
@@ -146,7 +147,7 @@ public function it_can_make_a_call()
146147
$channel->send(new NotifiableWithAttribute, $this->notification);
147148
}
148149

149-
/** @test */
150+
#[Test]
150151
public function it_cant_make_a_call_when_the_from_config_is_missing()
151152
{
152153
$message = TwilioCallMessage::create('http://example.com');

tests/Unit/TwilioCallMessageTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace NotificationChannels\Twilio\Tests\Unit;
44

55
use NotificationChannels\Twilio\TwilioCallMessage;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class TwilioCallMessageTest extends TwilioMessageTestCase
89
{
@@ -16,31 +17,31 @@ protected function setUp(): void
1617
$this->message = new TwilioCallMessage;
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function it_can_accept_a_message_when_constructing_a_message()
2122
{
2223
$message = new TwilioCallMessage('http://example.com');
2324

2425
$this->assertEquals('http://example.com', $message->content);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_provides_a_create_method()
2930
{
3031
$message = TwilioCallMessage::create('http://example.com');
3132

3233
$this->assertEquals('http://example.com', $message->content);
3334
}
3435

35-
/** @test */
36+
#[Test]
3637
public function it_can_set_the_url()
3738
{
3839
$this->message->url('http://example.com');
3940

4041
$this->assertEquals('http://example.com', $this->message->content);
4142
}
4243

43-
/** @test */
44+
#[Test]
4445
public function it_can_set_optional_parameters()
4546
{
4647
$message = TwilioCallMessage::create('myMessage');

tests/Unit/TwilioChannelTest.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use NotificationChannels\Twilio\TwilioChannel;
1414
use NotificationChannels\Twilio\TwilioConfig;
1515
use NotificationChannels\Twilio\TwilioSmsMessage;
16+
use PHPUnit\Framework\Attributes\Test;
1617
use Twilio\Exceptions\RestException;
1718

1819
class TwilioChannelTest extends MockeryTestCase
@@ -37,7 +38,7 @@ protected function setUp(): void
3738
$this->channel = new TwilioChannel($this->twilio, $this->dispatcher);
3839
}
3940

40-
/** @test */
41+
#[Test]
4142
public function it_will_not_send_a_message_if_not_enabled()
4243
{
4344
$notifiable = new Notifiable;
@@ -54,7 +55,7 @@ public function it_will_not_send_a_message_if_not_enabled()
5455
$this->assertNull($result);
5556
}
5657

57-
/** @test */
58+
#[Test]
5859
public function it_will_not_send_a_message_without_known_receiver()
5960
{
6061
$notifiable = new Notifiable;
@@ -75,7 +76,7 @@ public function it_will_not_send_a_message_without_known_receiver()
7576
$this->assertNull($result);
7677
}
7778

78-
/** @test */
79+
#[Test]
7980
public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_the_notifiable()
8081
{
8182
$notifiable = new NotifiableWithMethod;
@@ -91,7 +92,7 @@ public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_
9192
$this->channel->send($notifiable, $notification);
9293
}
9394

94-
/** @test */
95+
#[Test]
9596
public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_the_notifiable_if_it_uses_the_twilio_channel_explicitly()
9697
{
9798
$notifiable = new NotifiableWithTwilioChannel;
@@ -107,7 +108,7 @@ public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_
107108
$this->channel->send($notifiable, $notification);
108109
}
109110

110-
/** @test */
111+
#[Test]
111112
public function it_will_make_a_call_to_the_phone_number_attribute_of_the_notifiable()
112113
{
113114
$notifiable = new NotifiableWithAttribute;
@@ -123,7 +124,7 @@ public function it_will_make_a_call_to_the_phone_number_attribute_of_the_notifia
123124
$this->channel->send($notifiable, $notification);
124125
}
125126

126-
/** @test */
127+
#[Test]
127128
public function it_will_convert_a_string_to_a_sms_message()
128129
{
129130
$notifiable = new NotifiableWithAttribute;
@@ -138,7 +139,7 @@ public function it_will_convert_a_string_to_a_sms_message()
138139
$this->channel->send($notifiable, $notification);
139140
}
140141

141-
/** @test */
142+
#[Test]
142143
public function it_will_fire_an_event_in_case_of_an_invalid_message()
143144
{
144145
$notifiable = new NotifiableWithAttribute;
@@ -160,7 +161,7 @@ public function it_will_fire_an_event_in_case_of_an_invalid_message()
160161
$this->channel->send($notifiable, $notification);
161162
}
162163

163-
/** @test */
164+
#[Test]
164165
public function it_will_ignore_specific_error_codes()
165166
{
166167
$notifiable = new NotifiableWithAttribute;
@@ -184,7 +185,7 @@ public function it_will_ignore_specific_error_codes()
184185
$this->channel->send($notifiable, $notification);
185186
}
186187

187-
/** @test */
188+
#[Test]
188189
public function it_will_rethrow_non_ignored_error_codes()
189190
{
190191
$notifiable = new NotifiableWithAttribute;
@@ -210,7 +211,7 @@ public function it_will_rethrow_non_ignored_error_codes()
210211
$this->channel->send($notifiable, $notification);
211212
}
212213

213-
/** @test */
214+
#[Test]
214215
public function it_will_ignore_all_error_codes()
215216
{
216217
$notifiable = new NotifiableWithAttribute;
@@ -232,7 +233,7 @@ public function it_will_ignore_all_error_codes()
232233
$this->channel->send($notifiable, $notification);
233234
}
234235

235-
/** @test */
236+
#[Test]
236237
public function it_will_send_using_alphanumeric_if_notifiable_can_receive()
237238
{
238239
$notifiable = new NotifiableWithAlphanumericSender;

tests/Unit/TwilioConfigTest.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace NotificationChannels\Twilio\Tests\Unit;
44

55
use NotificationChannels\Twilio\TwilioConfig;
6+
use PHPUnit\Framework\Attributes\Test;
67
use PHPUnit\Framework\TestCase;
78

89
class TwilioConfigTest extends TestCase
@@ -12,15 +13,15 @@ private function config(array $config = []): TwilioConfig
1213
return new TwilioConfig($config);
1314
}
1415

15-
/** @test */
16+
#[Test]
1617
public function it_returns_a_boolean_wether_it_is_is_enabled_or_not()
1718
{
1819
$this->assertTrue($this->config()->enabled()); // defaults to true
1920
$this->assertTrue($this->config(['enabled' => true])->enabled());
2021
$this->assertFalse($this->config(['enabled' => false])->enabled());
2122
}
2223

23-
/** @test */
24+
#[Test]
2425
public function it_defaults_to_null_for_config_keys_with_a_string_return_type()
2526
{
2627
$config = $this->config();
@@ -35,7 +36,7 @@ public function it_defaults_to_null_for_config_keys_with_a_string_return_type()
3536
$this->assertNull($config->getDebugTo());
3637
}
3738

38-
/** @test */
39+
#[Test]
3940
public function it_returns_a_string_for_config_keys_with_a_string_return_type()
4041
{
4142
$config = $this->config([
@@ -59,14 +60,14 @@ public function it_returns_a_string_for_config_keys_with_a_string_return_type()
5960
$this->assertEquals('valid-debug-to', $config->getDebugTo());
6061
}
6162

62-
/** @test */
63+
#[Test]
6364
public function it_returns_an_array_of_ignored_codes()
6465
{
6566
$this->assertEquals([], $this->config()->getIgnoredErrorCodes()); // defaults to empty array
6667
$this->assertEquals([1, 2], $this->config(['ignored_error_codes' => [1, 2]])->getIgnoredErrorCodes());
6768
}
6869

69-
/** @test */
70+
#[Test]
7071
public function it_returns_a_boolean_wether_the_error_code_is_ignored_or_not()
7172
{
7273
$config = $this->config(['ignored_error_codes' => [1, 2]]);
@@ -80,15 +81,15 @@ public function it_returns_a_boolean_wether_the_error_code_is_ignored_or_not()
8081
$this->assertTrue($config->isIgnoredErrorCode(3));
8182
}
8283

83-
/** @test */
84+
#[Test]
8485
public function it_returns_a_boolean_wether_shorten_urls_is_enabled_or_not()
8586
{
8687
$this->assertFalse($this->config()->isShortenUrlsEnabled()); // defaults to false
8788
$this->assertTrue($this->config(['shorten_urls' => true])->isShortenUrlsEnabled());
8889
$this->assertFalse($this->config(['shorten_urls' => false])->isShortenUrlsEnabled());
8990
}
9091

91-
/** @test */
92+
#[Test]
9293
public function it_returns_a_boolean_wether_token_auth_is_used_or_not()
9394
{
9495
// No values set...
@@ -102,7 +103,7 @@ public function it_returns_a_boolean_wether_token_auth_is_used_or_not()
102103
$this->assertTrue($this->config(['auth_token' => 'valid', 'account_sid' => 'valid'])->usingTokenAuth());
103104
}
104105

105-
/** @test */
106+
#[Test]
106107
public function it_returns_a_boolean_wether_username_password_auth_is_used_or_not()
107108
{
108109
// No values set...

tests/Unit/TwilioMessageTestCase.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,36 @@
44

55
use Mockery\Adapter\Phpunit\MockeryTestCase;
66
use NotificationChannels\Twilio\TwilioMessage;
7+
use PHPUnit\Framework\Attributes\Test;
78

89
abstract class TwilioMessageTestCase extends MockeryTestCase
910
{
1011
/** @var TwilioMessage */
1112
protected $message;
1213

13-
/** @test */
14+
#[Test]
1415
abstract public function it_can_accept_a_message_when_constructing_a_message();
1516

16-
/** @test */
17+
#[Test]
1718
abstract public function it_provides_a_create_method();
1819

19-
/** @test */
20+
#[Test]
2021
public function it_can_set_the_content()
2122
{
2223
$this->message->content('myMessage');
2324

2425
$this->assertEquals('myMessage', $this->message->content);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_set_the_from()
2930
{
3031
$this->message->from('+1234567890');
3132

3233
$this->assertEquals('+1234567890', $this->message->from);
3334
}
3435

35-
/** @test */
36+
#[Test]
3637
public function it_can_return_the_from_using_getter()
3738
{
3839
$this->message->from('+1234567890');

0 commit comments

Comments
 (0)