Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slunak committed Aug 8, 2020
1 parent d67de62 commit e80d6ce
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 186 deletions.
33 changes: 29 additions & 4 deletions tests/Api/Glances/GlanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPUnit\Framework\TestCase;
use Serhiy\Pushover\Api\Glances\GlanceDataFields;
use Serhiy\Pushover\Application;
use Serhiy\Pushover\Client\Response\GlancesResponse;
use Serhiy\Pushover\Recipient;

/**
Expand All @@ -27,8 +28,8 @@ class GlanceTest extends TestCase
*/
public function testCanBeCreated(): Glance
{
$application = new Application("zaGDORePK8gMaC0QOYAMyEEuzJnyUi"); // using dummy token
$recipient = new Recipient("uQiRzpo4DXghDmr9QzzfQu27cmVRsG"); // using dummy user key
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$recipient = new Recipient("aaaa1111AAAA1111bbbb2222BBBB22"); // using dummy user key
$glanceDataFields = new GlanceDataFields();

$glance = new Glance($application, $glanceDataFields);
Expand Down Expand Up @@ -72,7 +73,7 @@ public function testGetRecipient(Glance $glance)
*/
public function testSetApplication(Glance $glance)
{
$application = new Application("zaGDORePK8gMaC0QOYAMyEEuzJnyUi"); // using dummy token
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$glance->setApplication($application);

$this->assertInstanceOf(Application::class, $glance->getApplication());
Expand All @@ -96,7 +97,7 @@ public function testSetGlanceDataFields(Glance $glance)
*/
public function testSetRecipient(Glance $glance)
{
$recipient = new Recipient("uQiRzpo4DXghDmr9QzzfQu27cmVRsG"); // using dummy user key
$recipient = new Recipient("aaaa1111AAAA1111bbbb2222BBBB22"); // using dummy user key
$glance->setRecipient($recipient);

$this->assertInstanceOf(Recipient::class, $recipient);
Expand All @@ -123,4 +124,28 @@ public function testHasRecipient(Glance $glance)
{
$this->assertTrue($glance->hasRecipient());
}

/**
* @group Integration
*/
public function testPush()
{
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$recipient = new Recipient("aaaa1111AAAA1111bbbb2222BBBB22"); // using dummy user key

$glanceDataFields = new GlanceDataFields();
$glanceDataFields
->setTitle("Title")
->setText("Text Test")
->setSubtext("Subtext Test")
->setCount(199)
->setPercent(99)
;

$glance = new Glance($application, $glanceDataFields);
$glance->setRecipient($recipient);
$response = $glance->push();

$this->assertInstanceOf(GlancesResponse::class, $response);
}
}
22 changes: 18 additions & 4 deletions tests/Api/Groups/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Serhiy\Pushover\Api\Groups\Group;
use PHPUnit\Framework\TestCase;
use Serhiy\Pushover\Application;
use Serhiy\Pushover\Client\Response\RetrieveGroupResponse;

/**
* @author Serhiy Lunak
Expand All @@ -25,8 +26,8 @@ class GroupTest extends TestCase
*/
public function testCanBeCreated(): Group
{
$application = new Application("zaGDORePK8gMaC0QOYAMyEEuzJnyUi"); // using dummy token
$group = new Group("uoJCttEFQo8uoZ6REZHMGBjX2pmcdJ", $application); // using dummy group key
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$group = new Group("eeee5555EEEE5555ffff6666FFFF66", $application); // using dummy group key

$this->assertInstanceOf(Group::class, $group);

Expand All @@ -40,7 +41,7 @@ public function testCanBeCreated(): Group
public function testGetApplication(Group $group)
{
$this->assertInstanceOf(Application::class, $group->getApplication());
$this->assertEquals("zaGDORePK8gMaC0QOYAMyEEuzJnyUi", $group->getApplication()->getToken());
$this->assertEquals("cccc3333CCCC3333dddd4444DDDD44", $group->getApplication()->getToken());
}

/**
Expand All @@ -49,6 +50,19 @@ public function testGetApplication(Group $group)
*/
public function testGetKey(Group $group)
{
$this->assertEquals("uoJCttEFQo8uoZ6REZHMGBjX2pmcdJ", $group->getKey());
$this->assertEquals("eeee5555EEEE5555ffff6666FFFF66", $group->getKey());
}

/**
* @group Integration
*/
public function testRetrieveGroupInformation()
{
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$group = new Group("eeee5555EEEE5555ffff6666FFFF66", $application);

$response = $group->retrieveGroupInformation();

$this->assertInstanceOf(RetrieveGroupResponse::class, $response);
}
}
22 changes: 18 additions & 4 deletions tests/Api/Licensing/LicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Serhiy\Pushover\Api\Licensing\License;
use PHPUnit\Framework\TestCase;
use Serhiy\Pushover\Application;
use Serhiy\Pushover\Client\Response\LicenseResponse;
use Serhiy\Pushover\Exception\InvalidArgumentException;
use Serhiy\Pushover\Recipient;

Expand All @@ -24,7 +25,7 @@ class LicenseTest extends TestCase
*/
public function testCanBeCreated(): License
{
$application = new Application("zaGDORePK8gMaC0QOYAMyEEuzJnyUi"); // using dummy token
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$license = new License($application);

$this->assertInstanceOf(License::class, $license);
Expand All @@ -47,7 +48,7 @@ public function testGetApplication(License $license)
*/
public function testSetApplication(License $license)
{
$application = new Application("zaGDORePK8gMaC0QOYAMyEEuzJnyUi"); // using dummy token
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$license->setApplication($application);

$this->assertInstanceOf(Application::class, $license->getApplication());
Expand All @@ -68,7 +69,7 @@ public function testGetRecipient(License $license)
*/
public function testSetRecipient(License $license)
{
$recipient = new Recipient("uQiRzpo4DXghDmr9QzzfQu27cmVRsG"); // using dummy user key
$recipient = new Recipient("aaaa1111AAAA1111bbbb2222BBBB22"); // using dummy user key

$license->setRecipient($recipient);
$this->assertInstanceOf(Recipient::class, $license->getRecipient());
Expand Down Expand Up @@ -132,7 +133,7 @@ public function testSetOs(License $license)
*/
public function testCanBeAssigned(License $license)
{
$recipient = new Recipient("uQiRzpo4DXghDmr9QzzfQu27cmVRsG"); // using dummy user key
$recipient = new Recipient("aaaa1111AAAA1111bbbb2222BBBB22"); // using dummy user key
$email = '[email protected]';

$this->assertFalse($license->canBeAssigned());
Expand Down Expand Up @@ -165,4 +166,17 @@ public function testGetAvailableOsTypes(License $license)

$this->assertEquals($licenseTypes, $license->getAvailableOsTypes());
}

/**
* @group Integration
*/
public function testCheckCredits()
{
$application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token
$license = new License($application);

$response = $license->checkCredits();

$this->assertInstanceOf(LicenseResponse::class, $response);
}
}
42 changes: 0 additions & 42 deletions tests/Api/Message/ApplicationTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions tests/Api/Message/AttachmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testSetFilename(Attachment $attachment)
* @depends testCanBeCreated
* @param Attachment $attachment
*/
public function testSupportedAttachmentTypes(Attachment $attachment)
public function testGetSupportedAttachmentTypes(Attachment $attachment)
{
$supportedAttachmentsTypes = new \ReflectionClass(Attachment::class);

Expand All @@ -101,7 +101,7 @@ public function testSupportedAttachmentTypes(Attachment $attachment)
* @depends testCanBeCreated
* @param Attachment $attachment
*/
public function testSupportedAttachmentExtensions(Attachment $attachment)
public function testGetSupportedAttachmentExtensions(Attachment $attachment)
{
$supportedAttachmentExtensions = array(
'bmp', 'gif', 'ico', 'jpeg', 'jpg', 'png', 'svg', 'tif', 'tiff', 'webp'
Expand Down
Loading

0 comments on commit e80d6ce

Please sign in to comment.