Skip to content

Commit

Permalink
fix(tests): migrate from phpdocs to attributes (#419)
Browse files Browse the repository at this point in the history
phpdocs are deprecated in phpunit11
  • Loading branch information
Rotzbua authored Feb 4, 2025
1 parent b9c07b4 commit a2b1c0a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <?php and declare.
'global_namespace_import' => ['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,
Expand Down
5 changes: 2 additions & 3 deletions tests/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/MessageSentReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
3 changes: 2 additions & 1 deletion tests/PushServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions tests/SubscriptionTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php declare(strict_types=1);

use Minishlink\WebPush\Subscription;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @covers \Minishlink\WebPush\Subscription
*/
#[CoversClass(Subscription::class)]
class SubscriptionTest extends PHPUnit\Framework\TestCase
{
public function testCreateMinimal(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

use Jose\Component\KeyManagement\JWKFactory;
use Minishlink\WebPush\Utils;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Minishlink\WebPush\Utils
*/
#[CoversClass(Utils::class)]
final class UtilsTest extends TestCase
{
public function testSerializePublicKey(): void
Expand Down
9 changes: 2 additions & 7 deletions tests/VAPIDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

use Minishlink\WebPush\Utils;
use Minishlink\WebPush\VAPID;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @covers \Minishlink\WebPush\VAPID
*/
#[CoversClass(VAPID::class)]
final class VAPIDTest extends PHPUnit\Framework\TestCase
{
public static function vapidProvider(): array
Expand Down Expand Up @@ -74,10 +73,6 @@ public function testGetVapidHeaders(string $audience, array $vapid, string $cont
}
}

/**
* @param string $auth
* @return array
*/
private function explodeAuthorization(string $auth): array
{
$auth = explode('.', $auth);
Expand Down
7 changes: 2 additions & 5 deletions tests/WebPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
use Minishlink\WebPush\Subscription;
use Minishlink\WebPush\SubscriptionInterface;
use Minishlink\WebPush\WebPush;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @covers \Minishlink\WebPush\WebPush
*/
#[CoversClass(WebPush::class)]
final class WebPushTest extends PHPUnit\Framework\TestCase
{
private static array $endpoints;
Expand Down Expand Up @@ -135,8 +134,6 @@ public static function notificationProvider(): array
}

/**
* @param SubscriptionInterface $subscription
* @param string $payload
* @throws ErrorException
*/
#[dataProvider('notificationProvider')]
Expand Down

0 comments on commit a2b1c0a

Please sign in to comment.