From d664aca3df38768499704b03c8294054c7078490 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Sun, 1 Sep 2024 10:38:00 +0200 Subject: [PATCH] Require `phpunit/phpunit` 11 (#76) --- composer.json | 2 +- rector.php | 5 ++ src/Client/MessageClient.php | 2 +- tests/Api/Glances/GlanceTest.php | 38 +++++---------- tests/Api/Groups/GroupTest.php | 22 +++------ tests/Api/Licensing/LicenseTest.php | 46 ++++++------------- tests/Api/Message/AttachmentTest.php | 25 +++------- tests/Api/Message/CustomSoundTest.php | 21 +++------ tests/Api/Message/NotificationTest.php | 30 ++++-------- tests/Api/Message/PriorityTest.php | 13 ++---- tests/Api/Message/SoundTest.php | 13 ++---- tests/Api/Receipts/ReceiptTest.php | 14 ++---- tests/Api/Subscription/SubscriptionTest.php | 14 ++---- .../UserGroupValidation/ValidationTest.php | 10 ++-- tests/ApplicationTest.php | 5 +- tests/Client/CancelRetryClientTest.php | 9 ++-- tests/Client/ReceiptClientTest.php | 5 +- tests/Client/Request/RequestTest.php | 13 ++---- .../Response/ListGroupsResponseTest.php | 5 +- tests/Client/Response/ReceiptResponseTest.php | 37 ++++----------- .../Response/RetrieveGroupResponseTest.php | 9 ++-- .../UserGroupValidationResponseTest.php | 13 ++---- .../Client/UserGroupValidationClientTest.php | 9 ++-- tests/RecipientTest.php | 33 ++++--------- 24 files changed, 124 insertions(+), 269 deletions(-) diff --git a/composer.json b/composer.json index d6fe352..f304894 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "ergebnis/php-cs-fixer-config": "^6.34", "friendsofphp/php-cs-fixer": "^3.61", "phpstan/phpstan": "^1.11", - "phpunit/phpunit": "*", + "phpunit/phpunit": "^11.0", "rector/rector": "^1.2" }, "autoload": { diff --git a/rector.php b/rector.php index 6a033c8..3576cc4 100644 --- a/rector.php +++ b/rector.php @@ -12,6 +12,7 @@ */ use Rector\Config\RectorConfig; +use Rector\PHPUnit\Set\PHPUnitSetList; return RectorConfig::configure() ->withPaths([ @@ -20,4 +21,8 @@ __DIR__.'/tests', ]) ->withPhpSets(php82: true) + ->withSets([ + PHPUnitSetList::PHPUNIT_110, + ]) + ->withImportNames(importNames: true) ->withTypeCoverageLevel(0); diff --git a/src/Client/MessageClient.php b/src/Client/MessageClient.php index 3d44569..4bb6d30 100644 --- a/src/Client/MessageClient.php +++ b/src/Client/MessageClient.php @@ -40,7 +40,7 @@ public function buildApiUrl(): string /** * Builds array for CURLOPT_POSTFIELDS curl argument. * - * @return array + * @return array */ public function buildCurlPostFields(Notification $notification): array { diff --git a/tests/Api/Glances/GlanceTest.php b/tests/Api/Glances/GlanceTest.php index 67a3d43..88f7c79 100644 --- a/tests/Api/Glances/GlanceTest.php +++ b/tests/Api/Glances/GlanceTest.php @@ -13,6 +13,8 @@ namespace Api\Glances; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Glances\Glance; use Serhiy\Pushover\Api\Glances\GlanceDataFields; @@ -39,33 +41,25 @@ public function testCanBeConstructed(): Glance return $glance; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetGlanceDataFields(Glance $glance): void { $this->assertInstanceOf(GlanceDataFields::class, $glance->getGlanceDataFields()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(Glance $glance): void { $this->assertInstanceOf(Application::class, $glance->getApplication()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetRecipient(Glance $glance): void { $this->assertInstanceOf(Recipient::class, $glance->getRecipient()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetApplication(Glance $glance): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -74,9 +68,7 @@ public function testSetApplication(Glance $glance): void $this->assertInstanceOf(Application::class, $glance->getApplication()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetGlanceDataFields(Glance $glance): void { $glanceDataFields = new GlanceDataFields(); @@ -85,9 +77,7 @@ public function testSetGlanceDataFields(Glance $glance): void $this->assertInstanceOf(GlanceDataFields::class, $glance->getGlanceDataFields()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetRecipient(Glance $glance): void { $recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key @@ -96,9 +86,7 @@ public function testSetRecipient(Glance $glance): void $this->assertInstanceOf(Recipient::class, $recipient); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testHasAtLeastOneField(Glance $glance): void { $this->assertFalse($glance->hasAtLeastOneField()); @@ -108,17 +96,13 @@ public function testHasAtLeastOneField(Glance $glance): void $this->assertTrue($glance->hasAtLeastOneField()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testHasRecipient(Glance $glance): void { $this->assertTrue($glance->hasRecipient()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testPush(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/Groups/GroupTest.php b/tests/Api/Groups/GroupTest.php index dc2c8b0..c87f76c 100644 --- a/tests/Api/Groups/GroupTest.php +++ b/tests/Api/Groups/GroupTest.php @@ -13,6 +13,8 @@ namespace Api\Groups; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group as PHPUnitGroup; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Groups\Group; use Serhiy\Pushover\Application; @@ -35,26 +37,20 @@ public function testCanBeConstructed(): Group return $group; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(Group $group): void { $this->assertInstanceOf(Application::class, $group->getApplication()); $this->assertEquals('cccc3333CCCC3333dddd4444DDDD44', $group->getApplication()->getToken()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetKey(Group $group): void { $this->assertSame('eeee5555EEEE5555ffff6666FFFF66', $group->getKey()); } - /** - * @group Integration - */ + #[PHPUnitGroup('Integration')] public function testRetrieveGroupInformation(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -65,9 +61,7 @@ public function testRetrieveGroupInformation(): void $this->assertInstanceOf(RetrieveGroupResponse::class, $response); } - /** - * @group Integration - */ + #[PHPUnitGroup('Integration')] public function testCreate(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -78,9 +72,7 @@ public function testCreate(): void $this->assertInstanceOf(CreateGroupResponse::class, $response); } - /** - * @group Integration - */ + #[PHPUnitGroup('Integration')] public function testList(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/Licensing/LicenseTest.php b/tests/Api/Licensing/LicenseTest.php index ceefebe..8decedc 100644 --- a/tests/Api/Licensing/LicenseTest.php +++ b/tests/Api/Licensing/LicenseTest.php @@ -13,6 +13,8 @@ namespace Api\Licensing; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Licensing\License; use Serhiy\Pushover\Application; @@ -32,17 +34,13 @@ public function testCanBeConstructed(): License return $license; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(License $license): void { $this->assertInstanceOf(Application::class, $license->getApplication()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetApplication(License $license): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -51,17 +49,13 @@ public function testSetApplication(License $license): void $this->assertInstanceOf(Application::class, $license->getApplication()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetRecipient(License $license): void { $this->assertNull($license->getRecipient()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetRecipient(License $license): void { $recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key @@ -73,17 +67,13 @@ public function testSetRecipient(License $license): void $this->assertNull($license->getRecipient()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetEmail(License $license): void { $this->assertNull($license->getEmail()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetEmail(License $license): void { $email = 'dummy@email.com'; @@ -95,17 +85,13 @@ public function testSetEmail(License $license): void $this->assertNull($license->getEmail()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetOs(License $license): void { $this->assertNull($license->getOs()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetOs(License $license): void { $license->setOs(License::OS_ANDROID); @@ -118,9 +104,7 @@ public function testSetOs(License $license): void $license->setOs('Wrong_OS'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testCanBeAssigned(License $license): void { $recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key @@ -141,9 +125,7 @@ public function testCanBeAssigned(License $license): void $this->assertFalse($license->canBeAssigned()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetAvailableOsTypes(License $license): void { $licenseTypes = [ @@ -156,9 +138,7 @@ public function testGetAvailableOsTypes(License $license): void $this->assertEquals($licenseTypes, $license->getAvailableOsTypes()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testCheckCredits(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/Message/AttachmentTest.php b/tests/Api/Message/AttachmentTest.php index 28ee674..fe0ade9 100644 --- a/tests/Api/Message/AttachmentTest.php +++ b/tests/Api/Message/AttachmentTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Attachment; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -44,25 +45,19 @@ public function testCannotBeConstructedWithInvalidExtension(): void new Attachment('/images/test.invalid', Attachment::MIME_TYPE_JPEG); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetMimeType(Attachment $attachment): void { $this->assertSame(Attachment::MIME_TYPE_JPEG, $attachment->getMimeType()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetFilename(Attachment $attachment): void { $this->assertSame('/images/test.jpeg', $attachment->getFilename()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetMimeType(Attachment $attachment): void { $attachment->setMimeType(Attachment::MIME_TYPE_JPEG); @@ -72,9 +67,7 @@ public function testSetMimeType(Attachment $attachment): void $attachment->setMimeType('image/invalid'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetFilename(Attachment $attachment): void { $attachment->setMimeType(Attachment::MIME_TYPE_JPEG); @@ -84,9 +77,7 @@ public function testSetFilename(Attachment $attachment): void $attachment->setMimeType('image/invalid'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetSupportedAttachmentTypes(Attachment $attachment): void { $supportedAttachmentsTypes = new \ReflectionClass(Attachment::class); @@ -94,9 +85,7 @@ public function testGetSupportedAttachmentTypes(Attachment $attachment): void $this->assertEquals($supportedAttachmentsTypes->getConstants(), $attachment->getSupportedAttachmentTypes()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetSupportedAttachmentExtensions(Attachment $attachment): void { $supportedAttachmentExtensions = [ diff --git a/tests/Api/Message/CustomSoundTest.php b/tests/Api/Message/CustomSoundTest.php index 74f57a8..4a62335 100644 --- a/tests/Api/Message/CustomSoundTest.php +++ b/tests/Api/Message/CustomSoundTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\CustomSound; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -29,17 +30,13 @@ public function testCanBeConstructed(): CustomSound return $customSound; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetCustomSound(CustomSound $customSound): void { $this->assertSame('door_open', $customSound->getCustomSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetCustomSound(CustomSound $customSound): void { $customSound->setCustomSound('warning'); @@ -55,9 +52,7 @@ public function testSetCustomSound(CustomSound $customSound): void $this->assertSame('bell-sound', $customSound->getCustomSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetExistingCustomSound(CustomSound $customSound): void { $this->expectException(InvalidArgumentException::class); @@ -65,9 +60,7 @@ public function testSetExistingCustomSound(CustomSound $customSound): void $customSound->setCustomSound('echo'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetInvalidCustomSound(CustomSound $customSound): void { $this->expectException(InvalidArgumentException::class); @@ -75,9 +68,7 @@ public function testSetInvalidCustomSound(CustomSound $customSound): void $customSound->setCustomSound('warning+door_open'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetLongCustomSound(CustomSound $customSound): void { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Api/Message/NotificationTest.php b/tests/Api/Message/NotificationTest.php index 0453d63..c22dc0f 100644 --- a/tests/Api/Message/NotificationTest.php +++ b/tests/Api/Message/NotificationTest.php @@ -13,6 +13,8 @@ namespace Api\Message; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Attachment; use Serhiy\Pushover\Api\Message\CustomSound; @@ -42,9 +44,7 @@ public function testCanBeConstructed(): Notification return $notification; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetSound(Notification $notification): void { $notification->setSound(new Sound(Sound::PUSHOVER)); @@ -52,9 +52,7 @@ public function testSetSound(Notification $notification): void $this->assertSame('pushover', $notification->getSound()->getSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetSoundNull(Notification $notification): void { $notification->setSound(null); @@ -62,9 +60,7 @@ public function testSetSoundNull(Notification $notification): void $this->assertNull($notification->getSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetCustomSound(Notification $notification): void { $notification->setCustomSound(new CustomSound('door_open')); @@ -72,9 +68,7 @@ public function testSetCustomSound(Notification $notification): void $this->assertSame('door_open', $notification->getCustomSound()->getCustomSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetCustomSoundNull(Notification $notification): void { $notification->setCustomSound(null); @@ -82,9 +76,7 @@ public function testSetCustomSoundNull(Notification $notification): void $this->assertNull($notification->getCustomSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetAttachment(Notification $notification): void { $notification->setAttachment(new Attachment('/path/to/file.jpg', Attachment::MIME_TYPE_JPEG)); @@ -93,9 +85,7 @@ public function testSetAttachment(Notification $notification): void $this->assertSame('image/jpeg', $notification->getAttachment()->getMimeType()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetAttachmentNull(Notification $notification): void { $notification->setAttachment(null); @@ -103,9 +93,7 @@ public function testSetAttachmentNull(Notification $notification): void $this->assertNull($notification->getAttachment()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testPush(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/Message/PriorityTest.php b/tests/Api/Message/PriorityTest.php index ce88efc..166a361 100644 --- a/tests/Api/Message/PriorityTest.php +++ b/tests/Api/Message/PriorityTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Priority; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -62,9 +63,7 @@ public function testEmergencyPriorityRequiresExtraParams(): void new Priority(Priority::EMERGENCY); } - /** - * @depends testCanBeConstructedWithEmergencyPriority - */ + #[Depends('testCanBeConstructedWithEmergencyPriority')] public function testSetCallback(Priority $priority): Priority { $priority->setCallback('https://callback.example.com'); @@ -74,17 +73,13 @@ public function testSetCallback(Priority $priority): Priority return $priority; } - /** - * @depends testSetCallback - */ + #[Depends('testSetCallback')] public function testGetCallback(Priority $priority): void { $this->assertSame('https://callback.example.com', $priority->getCallback()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testAvailablePriorities(Priority $priority): void { $availablePriorities = new \ReflectionClass(Priority::class); diff --git a/tests/Api/Message/SoundTest.php b/tests/Api/Message/SoundTest.php index ab4d24e..a462f8b 100644 --- a/tests/Api/Message/SoundTest.php +++ b/tests/Api/Message/SoundTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Sound; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -29,17 +30,13 @@ public function testCanBeConstructed(): Sound return $sound; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetSound(Sound $sound): void { $this->assertSame('pushover', $sound->getSound()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testAvailableSounds(Sound $sound): void { $availableSounds = new \ReflectionClass(Sound::class); @@ -47,9 +44,7 @@ public function testAvailableSounds(Sound $sound): void $this->assertEquals($availableSounds->getConstants(), $sound->getAvailableSounds()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetSound(Sound $sound): void { $sound->setSound(Sound::ECHO); diff --git a/tests/Api/Receipts/ReceiptTest.php b/tests/Api/Receipts/ReceiptTest.php index fcf60ba..b56d408 100644 --- a/tests/Api/Receipts/ReceiptTest.php +++ b/tests/Api/Receipts/ReceiptTest.php @@ -13,6 +13,8 @@ namespace Api\Receipts; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Receipts\Receipt; use Serhiy\Pushover\Application; @@ -35,9 +37,7 @@ public function testCanBeConstructed(): Receipt return $receipt; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(Receipt $receipt): void { $application = $receipt->getApplication(); @@ -46,9 +46,7 @@ public function testGetApplication(Receipt $receipt): void $this->assertSame('cccc3333CCCC3333dddd4444DDDD44', $application->getToken()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testQuery(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -59,9 +57,7 @@ public function testQuery(): void $this->assertInstanceOf(ReceiptResponse::class, $response); } - /** - * @group Integration - */ + #[Group('Integration')] public function testCancelRetry(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/Subscription/SubscriptionTest.php b/tests/Api/Subscription/SubscriptionTest.php index 17e5b43..0e60403 100644 --- a/tests/Api/Subscription/SubscriptionTest.php +++ b/tests/Api/Subscription/SubscriptionTest.php @@ -13,6 +13,8 @@ namespace Api\Subscription; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Subscription\Subscription; use Serhiy\Pushover\Application; @@ -34,25 +36,19 @@ public function testCanBeConstructed(): Subscription return $subscription; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetSubscriptionCode(Subscription $subscription): void { $this->assertSame('dummy-subscription-aaa111bbb222ccc', $subscription->getSubscriptionCode()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(Subscription $subscription): void { $this->assertInstanceOf(Application::class, $subscription->getApplication()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testMigrate(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/Api/UserGroupValidation/ValidationTest.php b/tests/Api/UserGroupValidation/ValidationTest.php index aacf479..8e84c0c 100644 --- a/tests/Api/UserGroupValidation/ValidationTest.php +++ b/tests/Api/UserGroupValidation/ValidationTest.php @@ -13,6 +13,8 @@ namespace Api\UserGroupValidation; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\UserGroupValidation\Validation; use Serhiy\Pushover\Application; @@ -34,18 +36,14 @@ public function testCanBeConstructed(): Validation return $validation; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetApplication(Validation $validation): void { $this->assertInstanceOf(Application::class, $validation->getApplication()); $this->assertSame('cccc3333CCCC3333dddd4444DDDD44', $validation->getApplication()->getToken()); } - /** - * @group Integration - */ + #[Group('Integration')] public function testValidate(): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token diff --git a/tests/ApplicationTest.php b/tests/ApplicationTest.php index 7e26609..c918325 100644 --- a/tests/ApplicationTest.php +++ b/tests/ApplicationTest.php @@ -11,6 +11,7 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Application; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -44,9 +45,7 @@ public function testCannotBeConstructedFromShortApiToken(): void new Application('token'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetToken(Application $application): void { $this->assertSame('cccc3333CCCC3333dddd4444DDDD44', $application->getToken()); diff --git a/tests/Client/CancelRetryClientTest.php b/tests/Client/CancelRetryClientTest.php index 0bf9f1a..0e54147 100644 --- a/tests/Client/CancelRetryClientTest.php +++ b/tests/Client/CancelRetryClientTest.php @@ -13,6 +13,7 @@ namespace Client; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Receipts\Receipt; use Serhiy\Pushover\Application; @@ -32,9 +33,7 @@ public function testCabBeCreated(): CancelRetryClient return $client; } - /** - * @depends testCabBeCreated - */ + #[Depends('testCabBeCreated')] public function testBuildCurlPostFields(CancelRetryClient $client): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -47,9 +46,7 @@ public function testBuildCurlPostFields(CancelRetryClient $client): void ], $curlPostFields); } - /** - * @depends testCabBeCreated - */ + #[Depends('testCabBeCreated')] public function testBuildApiUrl(CancelRetryClient $client): void { $this->assertEquals( diff --git a/tests/Client/ReceiptClientTest.php b/tests/Client/ReceiptClientTest.php index c4325f6..efab960 100644 --- a/tests/Client/ReceiptClientTest.php +++ b/tests/Client/ReceiptClientTest.php @@ -13,6 +13,7 @@ namespace Client; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\ReceiptClient; @@ -32,9 +33,7 @@ public function testCanBeConstructed(): ReceiptClient return $client; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testBuildApiUrl(ReceiptClient $client): void { $this->assertEquals( diff --git a/tests/Client/Request/RequestTest.php b/tests/Client/Request/RequestTest.php index d43d6f9..35da446 100644 --- a/tests/Client/Request/RequestTest.php +++ b/tests/Client/Request/RequestTest.php @@ -13,6 +13,7 @@ namespace Client\Request; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Request\Request; @@ -30,25 +31,19 @@ public function testCanBeCrated(): Request return $request; } - /** - * @depends testCanBeCrated - */ + #[Depends('testCanBeCrated')] public function testGetMethod(Request $request): void { $this->assertEquals(Request::POST, $request->getMethod()); } - /** - * @depends testCanBeCrated - */ + #[Depends('testCanBeCrated')] public function testGetApiUrl(Request $request): void { $this->assertEquals('https://test.com/api', $request->getApiUrl()); } - /** - * @depends testCanBeCrated - */ + #[Depends('testCanBeCrated')] public function testGetCurlPostFields(Request $request): void { $this->assertIsArray($request->getCurlPostFields()); diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 5e8a4bb..f885500 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -13,6 +13,7 @@ namespace Client\Response; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\ListGroupsResponse; @@ -30,9 +31,7 @@ public function testCanBeConstructed(): ListGroupsResponse return $response; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetGroups(ListGroupsResponse $response): void { $groups = $response->getGroups(); diff --git a/tests/Client/Response/ReceiptResponseTest.php b/tests/Client/Response/ReceiptResponseTest.php index dcf355e..b6fcba2 100644 --- a/tests/Client/Response/ReceiptResponseTest.php +++ b/tests/Client/Response/ReceiptResponseTest.php @@ -13,6 +13,7 @@ namespace Client\Response; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\ReceiptResponse; use Serhiy\Pushover\Recipient; @@ -42,74 +43,56 @@ public function testCanBeConstructed(): ReceiptResponse return $response; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetAcknowledgedBy(ReceiptResponse $response): void { $this->assertInstanceOf(Recipient::class, $response->getAcknowledgedBy()); $this->assertEquals('aaaa1111AAAA1111bbbb2222BBBB22', $response->getAcknowledgedBy()->getUserKey()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetAcknowledgedByDevice(ReceiptResponse $response): void { $this->assertEquals('test-device-1', $response->getAcknowledgedByDevice()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetExpiresAt(ReceiptResponse $response): void { $this->assertInstanceOf(\DateTime::class, $response->getExpiresAt()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetLastDeliveredAt(ReceiptResponse $response): void { $this->assertInstanceOf(\DateTime::class, $response->getLastDeliveredAt()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testIsAcknowledged(ReceiptResponse $response): void { $this->assertTrue($response->isAcknowledged()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetCalledBackAt(ReceiptResponse $response): void { $this->assertInstanceOf(\DateTime::class, $response->getCalledBackAt()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetAcknowledgedAt(ReceiptResponse $response): void { $this->assertInstanceOf(\DateTime::class, $response->getAcknowledgedAt()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testHasCalledBack(ReceiptResponse $response): void { $this->assertTrue($response->hasCalledBack()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testIsExpired(ReceiptResponse $response): void { $this->assertTrue($response->isExpired()); diff --git a/tests/Client/Response/RetrieveGroupResponseTest.php b/tests/Client/Response/RetrieveGroupResponseTest.php index 648202f..fb378ae 100644 --- a/tests/Client/Response/RetrieveGroupResponseTest.php +++ b/tests/Client/Response/RetrieveGroupResponseTest.php @@ -13,6 +13,7 @@ namespace Client\Response; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; use Serhiy\Pushover\Recipient; @@ -39,17 +40,13 @@ public function testCanBeConstructed(): RetrieveGroupResponse return $response; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetName(RetrieveGroupResponse $response): void { $this->assertEquals('Test Group', $response->getName()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetUsers(RetrieveGroupResponse $response): void { $recipient = $response->getUsers()[0]; diff --git a/tests/Client/Response/UserGroupValidationResponseTest.php b/tests/Client/Response/UserGroupValidationResponseTest.php index e7750d6..ae800b6 100644 --- a/tests/Client/Response/UserGroupValidationResponseTest.php +++ b/tests/Client/Response/UserGroupValidationResponseTest.php @@ -13,6 +13,7 @@ namespace Client\Response; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\UserGroupValidationResponse; @@ -41,25 +42,19 @@ public function testCanBeConstructed(): UserGroupValidationResponse return $response; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetLicenses(UserGroupValidationResponse $response): void { $this->assertEquals(['Android', 'iOS'], $response->getLicenses()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetDevices(UserGroupValidationResponse $response): void { $this->assertEquals(['test-device-1', 'test-device-2'], $response->getDevices()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetIsGroup(UserGroupValidationResponse $response): void { $this->assertFalse($response->isGroup()); diff --git a/tests/Client/UserGroupValidationClientTest.php b/tests/Client/UserGroupValidationClientTest.php index 48e58b5..ac6bc8a 100644 --- a/tests/Client/UserGroupValidationClientTest.php +++ b/tests/Client/UserGroupValidationClientTest.php @@ -13,6 +13,7 @@ namespace Client; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\UserGroupValidationClient; @@ -32,9 +33,7 @@ public function testCanBeConstructed(): UserGroupValidationClient return $client; } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testBuildCurlPostFields(UserGroupValidationClient $client): void { $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token @@ -47,9 +46,7 @@ public function testBuildCurlPostFields(UserGroupValidationClient $client): void ], $curlPostFields); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testBuildApiUrl(UserGroupValidationClient $client): void { $this->assertSame('https://api.pushover.net/1/users/validate.json', $client->buildApiUrl()); diff --git a/tests/RecipientTest.php b/tests/RecipientTest.php index 4fcff6c..376b927 100644 --- a/tests/RecipientTest.php +++ b/tests/RecipientTest.php @@ -11,6 +11,7 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Exception\InvalidArgumentException; use Serhiy\Pushover\Recipient; @@ -39,17 +40,13 @@ public function testCannotBeConstructed(): void new Recipient('Lorem ipsum dolor sit amet'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetUserKey(Recipient $recipient): void { $this->assertSame('aaaa1111AAAA1111bbbb2222BBBB22', $recipient->getUserKey()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetDevice(Recipient $recipient): void { $this->assertSame( @@ -61,51 +58,39 @@ public function testGetDevice(Recipient $recipient): void ); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetDeviceListCommaSeparated(Recipient $recipient): void { $this->assertSame('test-device-1,test-device-2', $recipient->getDeviceListCommaSeparated()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testIsDisabled(Recipient $recipient): void { $this->assertFalse($recipient->isDisabled()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testGetMemo(Recipient $recipient): void { $this->assertSame('This is test memo', $recipient->getMemo()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetIsDisabled(Recipient $recipient): void { $recipient->setIsDisabled(true); $this->assertTrue($recipient->isDisabled()); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testSetMemo(Recipient $recipient): void { $this->expectException(InvalidArgumentException::class); $recipient->setMemo('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'); } - /** - * @depends testCanBeConstructed - */ + #[Depends('testCanBeConstructed')] public function testAddDevice(Recipient $recipient): void { $this->expectException(InvalidArgumentException::class);