Skip to content

Commit

Permalink
Require phpunit/phpunit 11 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored Sep 1, 2024
1 parent 5e98137 commit d664aca
Show file tree
Hide file tree
Showing 24 changed files with 124 additions and 269 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
->withPaths([
Expand All @@ -20,4 +21,8 @@
__DIR__.'/tests',
])
->withPhpSets(php82: true)
->withSets([
PHPUnitSetList::PHPUNIT_110,
])
->withImportNames(importNames: true)
->withTypeCoverageLevel(0);
2 changes: 1 addition & 1 deletion src/Client/MessageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function buildApiUrl(): string
/**
* Builds array for CURLOPT_POSTFIELDS curl argument.
*
* @return array<string, null|\CURLFile|int|string>
* @return array<string, (null|\CURLFile|int|string)>
*/
public function buildCurlPostFields(Notification $notification): array
{
Expand Down
38 changes: 11 additions & 27 deletions tests/Api/Glances/GlanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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());
Expand All @@ -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
Expand Down
22 changes: 7 additions & 15 deletions tests/Api/Groups/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
46 changes: 13 additions & 33 deletions tests/Api/Licensing/LicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 = '[email protected]';
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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 = [
Expand All @@ -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
Expand Down
25 changes: 7 additions & 18 deletions tests/Api/Message/AttachmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -84,19 +77,15 @@ 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);

$this->assertEquals($supportedAttachmentsTypes->getConstants(), $attachment->getSupportedAttachmentTypes());
}

/**
* @depends testCanBeConstructed
*/
#[Depends('testCanBeConstructed')]
public function testGetSupportedAttachmentExtensions(Attachment $attachment): void
{
$supportedAttachmentExtensions = [
Expand Down
Loading

0 comments on commit d664aca

Please sign in to comment.