Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Aug 30, 2024
1 parent 553044c commit 8d1017f
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 87 deletions.
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
->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
20 changes: 11 additions & 9 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,25 +41,25 @@ public function testCanBeConstructed(): Glance
return $glance;
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetGlanceDataFields(Glance $glance): void
{
$this->assertInstanceOf(GlanceDataFields::class, $glance->getGlanceDataFields());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetApplication(Glance $glance): void
{
$this->assertInstanceOf(Application::class, $glance->getApplication());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetRecipient(Glance $glance): void
{
$this->assertInstanceOf(Recipient::class, $glance->getRecipient());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetApplication(Glance $glance): void
{
$application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token
Expand All @@ -66,7 +68,7 @@ public function testSetApplication(Glance $glance): void
$this->assertInstanceOf(Application::class, $glance->getApplication());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetGlanceDataFields(Glance $glance): void
{
$glanceDataFields = new GlanceDataFields();
Expand All @@ -75,7 +77,7 @@ public function testSetGlanceDataFields(Glance $glance): void
$this->assertInstanceOf(GlanceDataFields::class, $glance->getGlanceDataFields());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetRecipient(Glance $glance): void
{
$recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key
Expand All @@ -84,7 +86,7 @@ public function testSetRecipient(Glance $glance): void
$this->assertInstanceOf(Recipient::class, $recipient);
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testHasAtLeastOneField(Glance $glance): void
{
$this->assertFalse($glance->hasAtLeastOneField());
Expand All @@ -94,13 +96,13 @@ public function testHasAtLeastOneField(Glance $glance): void
$this->assertTrue($glance->hasAtLeastOneField());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testHasRecipient(Glance $glance): void
{
$this->assertTrue($glance->hasRecipient());
}

#[\PHPUnit\Framework\Attributes\Group('Integration')]
#[Group('Integration')]
public function testPush(): void
{
$application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token
Expand Down
5 changes: 3 additions & 2 deletions tests/Api/Groups/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Api\Groups;

use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Serhiy\Pushover\Api\Groups\Group;
use Serhiy\Pushover\Application;
Expand All @@ -35,14 +36,14 @@ public function testCanBeConstructed(): Group
return $group;
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetApplication(Group $group): void
{
$this->assertInstanceOf(Application::class, $group->getApplication());
$this->assertEquals('cccc3333CCCC3333dddd4444DDDD44', $group->getApplication()->getToken());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetKey(Group $group): void
{
$this->assertSame('eeee5555EEEE5555ffff6666FFFF66', $group->getKey());
Expand Down
24 changes: 13 additions & 11 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,13 +34,13 @@ public function testCanBeConstructed(): License
return $license;
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetApplication(License $license): void
{
$this->assertInstanceOf(Application::class, $license->getApplication());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetApplication(License $license): void
{
$application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token
Expand All @@ -47,13 +49,13 @@ public function testSetApplication(License $license): void
$this->assertInstanceOf(Application::class, $license->getApplication());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetRecipient(License $license): void
{
$this->assertNull($license->getRecipient());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetRecipient(License $license): void
{
$recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key
Expand All @@ -65,13 +67,13 @@ public function testSetRecipient(License $license): void
$this->assertNull($license->getRecipient());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetEmail(License $license): void
{
$this->assertNull($license->getEmail());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetEmail(License $license): void
{
$email = '[email protected]';
Expand All @@ -83,13 +85,13 @@ public function testSetEmail(License $license): void
$this->assertNull($license->getEmail());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetOs(License $license): void
{
$this->assertNull($license->getOs());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetOs(License $license): void
{
$license->setOs(License::OS_ANDROID);
Expand All @@ -102,7 +104,7 @@ public function testSetOs(License $license): void
$license->setOs('Wrong_OS');
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testCanBeAssigned(License $license): void
{
$recipient = new Recipient('aaaa1111AAAA1111bbbb2222BBBB22'); // using dummy user key
Expand All @@ -123,7 +125,7 @@ public function testCanBeAssigned(License $license): void
$this->assertFalse($license->canBeAssigned());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetAvailableOsTypes(License $license): void
{
$licenseTypes = [
Expand All @@ -136,7 +138,7 @@ public function testGetAvailableOsTypes(License $license): void
$this->assertEquals($licenseTypes, $license->getAvailableOsTypes());
}

#[\PHPUnit\Framework\Attributes\Group('Integration')]
#[Group('Integration')]
public function testCheckCredits(): void
{
$application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token
Expand Down
13 changes: 7 additions & 6 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,19 +45,19 @@ public function testCannotBeConstructedWithInvalidExtension(): void
new Attachment('/images/test.invalid', Attachment::MIME_TYPE_JPEG);
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetMimeType(Attachment $attachment): void
{
$this->assertSame(Attachment::MIME_TYPE_JPEG, $attachment->getMimeType());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetFilename(Attachment $attachment): void
{
$this->assertSame('/images/test.jpeg', $attachment->getFilename());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetMimeType(Attachment $attachment): void
{
$attachment->setMimeType(Attachment::MIME_TYPE_JPEG);
Expand All @@ -66,7 +67,7 @@ public function testSetMimeType(Attachment $attachment): void
$attachment->setMimeType('image/invalid');
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetFilename(Attachment $attachment): void
{
$attachment->setMimeType(Attachment::MIME_TYPE_JPEG);
Expand All @@ -76,15 +77,15 @@ public function testSetFilename(Attachment $attachment): void
$attachment->setMimeType('image/invalid');
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetSupportedAttachmentTypes(Attachment $attachment): void
{
$supportedAttachmentsTypes = new \ReflectionClass(Attachment::class);

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

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetSupportedAttachmentExtensions(Attachment $attachment): void
{
$supportedAttachmentExtensions = [
Expand Down
11 changes: 6 additions & 5 deletions tests/Api/Message/CustomSoundTest.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\CustomSound;
use Serhiy\Pushover\Exception\InvalidArgumentException;
Expand All @@ -29,13 +30,13 @@ public function testCanBeConstructed(): CustomSound
return $customSound;
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testGetCustomSound(CustomSound $customSound): void
{
$this->assertSame('door_open', $customSound->getCustomSound());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetCustomSound(CustomSound $customSound): void
{
$customSound->setCustomSound('warning');
Expand All @@ -51,23 +52,23 @@ public function testSetCustomSound(CustomSound $customSound): void
$this->assertSame('bell-sound', $customSound->getCustomSound());
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetExistingCustomSound(CustomSound $customSound): void
{
$this->expectException(InvalidArgumentException::class);

$customSound->setCustomSound('echo');
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetInvalidCustomSound(CustomSound $customSound): void
{
$this->expectException(InvalidArgumentException::class);

$customSound->setCustomSound('warning+door_open');
}

#[\PHPUnit\Framework\Attributes\Depends('testCanBeConstructed')]
#[Depends('testCanBeConstructed')]
public function testSetLongCustomSound(CustomSound $customSound): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
Loading

0 comments on commit 8d1017f

Please sign in to comment.