From a2b1c0a2f4472f661be15306dad82313d8687058 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Wed, 5 Feb 2025 00:12:46 +0100 Subject: [PATCH] fix(tests): migrate from phpdocs to attributes (#419) phpdocs are deprecated in phpunit11 --- .php-cs-fixer.php | 3 ++- tests/EncryptionTest.php | 5 ++--- tests/MessageSentReportTest.php | 5 ++--- tests/PushServiceTest.php | 3 ++- tests/SubscriptionTest.php | 5 ++--- tests/UtilsTest.php | 5 ++--- tests/VAPIDTest.php | 9 ++------- tests/WebPushTest.php | 7 ++----- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 0b5827d..9fccf94 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -7,8 +7,9 @@ '@PHP81Migration' => true, // Must be the same as the min PHP version. 'blank_line_after_opening_tag' => false, // Do not waste space between ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], - 'php_unit_test_class_requires_covers' => true, + 'php_unit_attributes' => true, 'php_unit_method_casing' => true, + 'php_unit_test_class_requires_covers' => true, // Do not enable by default. These rules require review!! (but they are useful) // '@PHP80Migration:risky' => true, // '@PHPUnit100Migration:risky' => true, diff --git a/tests/EncryptionTest.php b/tests/EncryptionTest.php index 1c124aa..13cd849 100644 --- a/tests/EncryptionTest.php +++ b/tests/EncryptionTest.php @@ -12,11 +12,10 @@ use Jose\Component\Core\JWK; use Minishlink\WebPush\Encryption; use Minishlink\WebPush\Utils; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -/** - * @covers \Minishlink\WebPush\Encryption - */ +#[CoversClass(Encryption::class)] final class EncryptionTest extends PHPUnit\Framework\TestCase { public function testBase64Encode(): void diff --git a/tests/MessageSentReportTest.php b/tests/MessageSentReportTest.php index ce6ca9a..1763111 100644 --- a/tests/MessageSentReportTest.php +++ b/tests/MessageSentReportTest.php @@ -7,12 +7,11 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Minishlink\WebPush\MessageSentReport; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -/** - * @covers \Minishlink\WebPush\MessageSentReport - */ +#[CoversClass(MessageSentReport::class)] class MessageSentReportTest extends TestCase { #[dataProvider('generateReportsWithExpiration')] diff --git a/tests/PushServiceTest.php b/tests/PushServiceTest.php index f4bc95d..805f4c4 100644 --- a/tests/PushServiceTest.php +++ b/tests/PushServiceTest.php @@ -11,14 +11,15 @@ use Minishlink\WebPush\MessageSentReport; use Minishlink\WebPush\Subscription; use Minishlink\WebPush\WebPush; +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; /** * Test with test server. - * @coversNothing */ #[group('online')] +#[CoversNothing] final class PushServiceTest extends PHPUnit\Framework\TestCase { private static int $timeout = 30; diff --git a/tests/SubscriptionTest.php b/tests/SubscriptionTest.php index 3e6b9a2..43787df 100644 --- a/tests/SubscriptionTest.php +++ b/tests/SubscriptionTest.php @@ -1,10 +1,9 @@