Skip to content

Commit 12c9433

Browse files
committed
test: resolve phpunit deprecations
1 parent e1f2334 commit 12c9433

5 files changed

+35
-29
lines changed

tests/ChannelTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
use NotificationChannels\WebPush\Events\NotificationSent;
1414
use NotificationChannels\WebPush\ReportHandler;
1515
use NotificationChannels\WebPush\WebPushChannel;
16+
use PHPUnit\Framework\Attributes\Test;
1617

1718
class ChannelTest extends TestCase
1819
{
19-
/** @test */
20+
#[Test]
2021
public function notification_can_be_sent(): void
2122
{
2223
Event::fake();
@@ -54,7 +55,7 @@ public function notification_can_be_sent(): void
5455
Event::assertDispatched(NotificationSent::class);
5556
}
5657

57-
/** @test */
58+
#[Test]
5859
public function subscriptions_with_invalid_endpoint_are_deleted(): void
5960
{
6061
Event::fake();

tests/HasPushSubscriptionsTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace NotificationChannels\WebPush\Test;
44

5+
use PHPUnit\Framework\Attributes\Test;
6+
57
class HasPushSubscriptionsTest extends TestCase
68
{
7-
/** @test */
9+
#[Test]
810
public function model_has_subscriptions(): void
911
{
1012
$this->createSubscription($this->testUser, 'foo');
@@ -15,7 +17,7 @@ public function model_has_subscriptions(): void
1517
$this->assertTrue($this->testUser->pushSubscriptions()->where('endpoint', 'bar')->exists());
1618
}
1719

18-
/** @test */
20+
#[Test]
1921
public function subscription_can_be_created(): void
2022
{
2123
$this->testUser->updatePushSubscription('foo', 'key', 'token', 'aesgcm');
@@ -27,7 +29,7 @@ public function subscription_can_be_created(): void
2729
$this->assertEquals('aesgcm', $subscription->content_encoding);
2830
}
2931

30-
/** @test */
32+
#[Test]
3133
public function exiting_subscription_can_be_updated_by_endpoint(): void
3234
{
3335
$this->testUser->updatePushSubscription('foo', 'key', 'token');
@@ -40,15 +42,15 @@ public function exiting_subscription_can_be_updated_by_endpoint(): void
4042
$this->assertEquals('another-token', $subscriptions[0]->auth_token);
4143
}
4244

43-
/** @test */
45+
#[Test]
4446
public function determinte_if_model_owns_subscription(): void
4547
{
4648
$subscription = $this->testUser->updatePushSubscription('foo');
4749

4850
$this->assertTrue($this->testUser->ownsPushSubscription($subscription));
4951
}
5052

51-
/** @test */
53+
#[Test]
5254
public function subscription_owned_by_another_model_is_deleted_and_saved_for_the_new_model(): void
5355
{
5456
$otherUser = $this->createUser(['email' => 'other@user.com']);
@@ -60,7 +62,7 @@ public function subscription_owned_by_another_model_is_deleted_and_saved_for_the
6062
$this->assertEquals(1, count($this->testUser->pushSubscriptions));
6163
}
6264

63-
/** @test */
65+
#[Test]
6466
public function subscription_can_be_deleted_by_endpoint(): void
6567
{
6668
$this->testUser->updatePushSubscription('foo');

tests/MessageTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace NotificationChannels\WebPush\Test;
44

55
use NotificationChannels\WebPush\WebPushMessage;
6+
use PHPUnit\Framework\Attributes\Test;
67
use PHPUnit\Framework\TestCase;
78

89
class MessageTest extends TestCase
@@ -16,15 +17,15 @@ protected function setUp(): void
1617
$this->message = new WebPushMessage;
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function title_can_be_set(): void
2122
{
2223
$this->message->title('Message title');
2324

2425
$this->assertEquals('Message title', $this->message->toArray()['title']);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function action_can_be_set(): void
2930
{
3031
$this->message->action('Some Action', 'some_action');
@@ -34,7 +35,7 @@ public function action_can_be_set(): void
3435
);
3536
}
3637

37-
/** @test */
38+
#[Test]
3839
public function action_can_be_set_with_icon(): void
3940
{
4041
$this->message->action('Some Action', 'some_action', '/icon.png');
@@ -44,95 +45,95 @@ public function action_can_be_set_with_icon(): void
4445
);
4546
}
4647

47-
/** @test */
48+
#[Test]
4849
public function badge_can_be_set(): void
4950
{
5051
$this->message->badge('/badge.jpg');
5152

5253
$this->assertEquals('/badge.jpg', $this->message->toArray()['badge']);
5354
}
5455

55-
/** @test */
56+
#[Test]
5657
public function body_can_be_set(): void
5758
{
5859
$this->message->body('Message body');
5960

6061
$this->assertEquals('Message body', $this->message->toArray()['body']);
6162
}
6263

63-
/** @test */
64+
#[Test]
6465
public function direction_can_be_set(): void
6566
{
6667
$this->message->dir('rtl');
6768

6869
$this->assertEquals('rtl', $this->message->toArray()['dir']);
6970
}
7071

71-
/** @test */
72+
#[Test]
7273
public function icon_can_be_set(): void
7374
{
7475
$this->message->icon('/icon.jpg');
7576

7677
$this->assertEquals('/icon.jpg', $this->message->toArray()['icon']);
7778
}
7879

79-
/** @test */
80+
#[Test]
8081
public function image_can_be_set(): void
8182
{
8283
$this->message->image('/image.jpg');
8384

8485
$this->assertEquals('/image.jpg', $this->message->toArray()['image']);
8586
}
8687

87-
/** @test */
88+
#[Test]
8889
public function lang_can_be_set(): void
8990
{
9091
$this->message->lang('en');
9192

9293
$this->assertEquals('en', $this->message->toArray()['lang']);
9394
}
9495

95-
/** @test */
96+
#[Test]
9697
public function renotify_can_be_set(): void
9798
{
9899
$this->message->renotify();
99100

100101
$this->assertTrue($this->message->toArray()['renotify']);
101102
}
102103

103-
/** @test */
104+
#[Test]
104105
public function require_interaction_can_be_set(): void
105106
{
106107
$this->message->requireInteraction();
107108

108109
$this->assertTrue($this->message->toArray()['requireInteraction']);
109110
}
110111

111-
/** @test */
112+
#[Test]
112113
public function tag_can_be_set(): void
113114
{
114115
$this->message->tag('tag1');
115116

116117
$this->assertEquals('tag1', $this->message->toArray()['tag']);
117118
}
118119

119-
/** @test */
120+
#[Test]
120121
public function vibration_pattern_can_be_set(): void
121122
{
122123
$this->message->vibrate([1, 2, 3]);
123124

124125
$this->assertEquals([1, 2, 3], $this->message->toArray()['vibrate']);
125126
}
126127

127-
/** @test */
128+
#[Test]
128129
public function arbitrary_data_can_be_set(): void
129130
{
130131
$this->message->data(['id' => 1]);
131132

132133
$this->assertEquals(['id' => 1], $this->message->toArray()['data']);
133134
}
134135

135-
/** @test */
136+
#[Test]
136137
public function options_can_be_set(): void
137138
{
138139
$this->message->options(['ttl' => 60]);

tests/PushSubscriptionModelTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace NotificationChannels\WebPush\Test;
44

55
use NotificationChannels\WebPush\PushSubscription;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class PushSubscriptionModelTest extends TestCase
89
{
9-
/** @test */
10+
#[Test]
1011
public function attributes_are_fillable(): void
1112
{
1213
$subscription = new PushSubscription([
@@ -22,7 +23,7 @@ public function attributes_are_fillable(): void
2223
$this->assertEquals('aesgcm', $subscription->content_encoding);
2324
}
2425

25-
/** @test */
26+
#[Test]
2627
public function subscription_can_be_found_by_endpoint(): void
2728
{
2829
$this->testUser->updatePushSubscription('endpoint');
@@ -31,7 +32,7 @@ public function subscription_can_be_found_by_endpoint(): void
3132
$this->assertEquals('endpoint', $subscription->endpoint);
3233
}
3334

34-
/** @test */
35+
#[Test]
3536
public function subscription_has_owner_model(): void
3637
{
3738
$this->testUser->updatePushSubscription('endpoint');

tests/VapidKeysGenerateCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use Illuminate\Support\Facades\Artisan;
66
use Illuminate\Support\Facades\File;
7+
use PHPUnit\Framework\Attributes\Test;
78

89
class VapidKeysGenerateCommandTest extends TestCase
910
{
10-
/** @test */
11+
#[Test]
1112
public function it_can_generate_and_show_vapid_keys1(): void
1213
{
1314
$exitCode = Artisan::call('webpush:vapid', ['--show' => true]);
@@ -16,7 +17,7 @@ public function it_can_generate_and_show_vapid_keys1(): void
1617
$this->seeInConsoleOutput('VAPID_PUBLIC_KEY=');
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function it_can_generate_and_show_vapid_keys2(): void
2122
{
2223
$exitCode = Artisan::call('webpush:vapid', ['--show' => true]);
@@ -25,7 +26,7 @@ public function it_can_generate_and_show_vapid_keys2(): void
2526
$this->seeInConsoleOutput('VAPID_PRIVATE_KEY=');
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_can_generate_and_set_vapid_keys(): void
3031
{
3132
if (File::isDirectory(__DIR__.'/temp')) {

0 commit comments

Comments
 (0)