Skip to content

Commit a2b1c0a

Browse files
authored
fix(tests): migrate from phpdocs to attributes (#419)
phpdocs are deprecated in phpunit11
1 parent b9c07b4 commit a2b1c0a

8 files changed

+16
-26
lines changed

.php-cs-fixer.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
'@PHP81Migration' => true, // Must be the same as the min PHP version.
88
'blank_line_after_opening_tag' => false, // Do not waste space between <?php and declare.
99
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
10-
'php_unit_test_class_requires_covers' => true,
10+
'php_unit_attributes' => true,
1111
'php_unit_method_casing' => true,
12+
'php_unit_test_class_requires_covers' => true,
1213
// Do not enable by default. These rules require review!! (but they are useful)
1314
// '@PHP80Migration:risky' => true,
1415
// '@PHPUnit100Migration:risky' => true,

tests/EncryptionTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
use Jose\Component\Core\JWK;
1313
use Minishlink\WebPush\Encryption;
1414
use Minishlink\WebPush\Utils;
15+
use PHPUnit\Framework\Attributes\CoversClass;
1516
use PHPUnit\Framework\Attributes\DataProvider;
1617

17-
/**
18-
* @covers \Minishlink\WebPush\Encryption
19-
*/
18+
#[CoversClass(Encryption::class)]
2019
final class EncryptionTest extends PHPUnit\Framework\TestCase
2120
{
2221
public function testBase64Encode(): void

tests/MessageSentReportTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
use GuzzleHttp\Psr7\Request;
88
use GuzzleHttp\Psr7\Response;
99
use Minishlink\WebPush\MessageSentReport;
10+
use PHPUnit\Framework\Attributes\CoversClass;
1011
use PHPUnit\Framework\Attributes\DataProvider;
1112
use PHPUnit\Framework\TestCase;
1213

13-
/**
14-
* @covers \Minishlink\WebPush\MessageSentReport
15-
*/
14+
#[CoversClass(MessageSentReport::class)]
1615
class MessageSentReportTest extends TestCase
1716
{
1817
#[dataProvider('generateReportsWithExpiration')]

tests/PushServiceTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
use Minishlink\WebPush\MessageSentReport;
1212
use Minishlink\WebPush\Subscription;
1313
use Minishlink\WebPush\WebPush;
14+
use PHPUnit\Framework\Attributes\CoversNothing;
1415
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\Attributes\Group;
1617

1718
/**
1819
* Test with test server.
19-
* @coversNothing
2020
*/
2121
#[group('online')]
22+
#[CoversNothing]
2223
final class PushServiceTest extends PHPUnit\Framework\TestCase
2324
{
2425
private static int $timeout = 30;

tests/SubscriptionTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php declare(strict_types=1);
22

33
use Minishlink\WebPush\Subscription;
4+
use PHPUnit\Framework\Attributes\CoversClass;
45

5-
/**
6-
* @covers \Minishlink\WebPush\Subscription
7-
*/
6+
#[CoversClass(Subscription::class)]
87
class SubscriptionTest extends PHPUnit\Framework\TestCase
98
{
109
public function testCreateMinimal(): void

tests/UtilsTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
use Jose\Component\KeyManagement\JWKFactory;
44
use Minishlink\WebPush\Utils;
5+
use PHPUnit\Framework\Attributes\CoversClass;
56
use PHPUnit\Framework\TestCase;
67

7-
/**
8-
* @covers \Minishlink\WebPush\Utils
9-
*/
8+
#[CoversClass(Utils::class)]
109
final class UtilsTest extends TestCase
1110
{
1211
public function testSerializePublicKey(): void

tests/VAPIDTest.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
use Minishlink\WebPush\Utils;
1212
use Minishlink\WebPush\VAPID;
13+
use PHPUnit\Framework\Attributes\CoversClass;
1314
use PHPUnit\Framework\Attributes\DataProvider;
1415

15-
/**
16-
* @covers \Minishlink\WebPush\VAPID
17-
*/
16+
#[CoversClass(VAPID::class)]
1817
final class VAPIDTest extends PHPUnit\Framework\TestCase
1918
{
2019
public static function vapidProvider(): array
@@ -74,10 +73,6 @@ public function testGetVapidHeaders(string $audience, array $vapid, string $cont
7473
}
7574
}
7675

77-
/**
78-
* @param string $auth
79-
* @return array
80-
*/
8176
private function explodeAuthorization(string $auth): array
8277
{
8378
$auth = explode('.', $auth);

tests/WebPushTest.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
use Minishlink\WebPush\Subscription;
1212
use Minishlink\WebPush\SubscriptionInterface;
1313
use Minishlink\WebPush\WebPush;
14+
use PHPUnit\Framework\Attributes\CoversClass;
1415
use PHPUnit\Framework\Attributes\DataProvider;
1516

16-
/**
17-
* @covers \Minishlink\WebPush\WebPush
18-
*/
17+
#[CoversClass(WebPush::class)]
1918
final class WebPushTest extends PHPUnit\Framework\TestCase
2019
{
2120
private static array $endpoints;
@@ -135,8 +134,6 @@ public static function notificationProvider(): array
135134
}
136135

137136
/**
138-
* @param SubscriptionInterface $subscription
139-
* @param string $payload
140137
* @throws ErrorException
141138
*/
142139
#[dataProvider('notificationProvider')]

0 commit comments

Comments
 (0)