diff options
author | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-17 10:28:02 +0100 |
---|---|---|
committer | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-17 10:28:02 +0100 |
commit | 0420fb5c1733a99d68504a28aeb9674ae1dfc25d (patch) | |
tree | a16162b3e0ad2b7d5bd466e1f6ed5278682eeb32 | |
parent | c9f274be08039838ab9b5e518dba5fc2c9c7c1b8 (diff) | |
download | ip1-php-sdk-0420fb5c1733a99d68504a28aeb9674ae1dfc25d.zip ip1-php-sdk-0420fb5c1733a99d68504a28aeb9674ae1dfc25d.tar.gz ip1-php-sdk-0420fb5c1733a99d68504a28aeb9674ae1dfc25d.tar.bz2 |
Minimized test skipping
Signed-off-by: Hannes Kindströmmer <hannes@kindstrommer.se>
-rw-r--r-- | tests/Core/AbstractEnviromentProvider.php | 10 | ||||
-rw-r--r-- | tests/Recipient/ContactTest.php | 14 | ||||
-rw-r--r-- | tests/SMS/LoggedOutGoingSMSTest.php | 5 |
3 files changed, 14 insertions, 15 deletions
diff --git a/tests/Core/AbstractEnviromentProvider.php b/tests/Core/AbstractEnviromentProvider.php index aa9ca15..2dc4494 100644 --- a/tests/Core/AbstractEnviromentProvider.php +++ b/tests/Core/AbstractEnviromentProvider.php @@ -7,7 +7,7 @@ use IP1\RESTClient\Core\Communicator; abstract class AbstractEnviromentProvider extends TestCase { - protected $communicator; + private $communicator; private $communicatorEnabled = false; public function __construct() { @@ -21,4 +21,12 @@ abstract class AbstractEnviromentProvider extends TestCase { return $this->communicatorEnabled; } + public function getCommunicator(): ?Communicator + { + if (!$this->isCommunicatorEnabled()) { + $this->markTestSkipped("Communicator is not enabled skipping test"); + return null; + } + return $this->communicator; + } } diff --git a/tests/Recipient/ContactTest.php b/tests/Recipient/ContactTest.php index bfa1232..47d7d83 100644 --- a/tests/Recipient/ContactTest.php +++ b/tests/Recipient/ContactTest.php @@ -46,11 +46,8 @@ class ContactTest extends AbstractEnviromentProvider */ public function testAPI() { - if (!$this->isCommunicatorEnabled()) { - $this->markTestSkipped("Communicator is not enabled skipping test"); - } $contact = RecipientFactory::createContactFromJSON($this->completeContactString); - $newContact = $this->communicator->add($contact); + $newContact = $this->getCommunicator()->add($contact); $this->assertEquals(ProcessedContact::class, get_class($newContact)); $this->assertEquals($contact->getEmail(), $newContact->getEmail()); $this->assertEquals($contact->getFirstName(), $newContact->getFirstName()); @@ -64,7 +61,7 @@ class ContactTest extends AbstractEnviromentProvider $newContact->setLastName("Swann"); $newContact->setTitle("Queen"); - $alteredContact = $this->communicator->edit($newContact); + $alteredContact = $this->getCommunicator()->edit($newContact); $this->assertEquals(ProcessedContact::class, get_class($alteredContact)); $this->assertEquals($newContact->getEmail(), $alteredContact->getEmail()); $this->assertEquals($newContact->getFirstName(), $alteredContact->getFirstName()); @@ -75,7 +72,7 @@ class ContactTest extends AbstractEnviromentProvider $this->assertEquals($newContact->getTitle(), $alteredContact->getTitle()); $this->assertEquals($newContact->getID(), $alteredContact->getID()); - $deletedContact = $this->communicator->remove($newContact); + $deletedContact = $this->getCommunicator()->remove($newContact); $this->assertEquals(ProcessedContact::class, get_class($deletedContact)); $this->assertEquals($newContact->getEmail(), $deletedContact->getEmail()); $this->assertEquals($newContact->getFirstName(), $deletedContact->getFirstName()); @@ -91,12 +88,9 @@ class ContactTest extends AbstractEnviromentProvider */ public function testIsContactBookEmpty() { - if (!$this->isCommunicatorEnabled()) { - $this->markTestSkipped("Communicator is not enabled skipping test"); - } $contacts = RecipientFactory::createProcessedContactFromStdClassArray( json_decode( - $this->communicator->get("api/contacts") + $this->getCommunicator()->get("api/contacts") ) ); $this->assertEquals([], $contacts->getArrayCopy); diff --git a/tests/SMS/LoggedOutGoingSMSTest.php b/tests/SMS/LoggedOutGoingSMSTest.php index 0abe2ff..1810939 100644 --- a/tests/SMS/LoggedOutGoingSMSTest.php +++ b/tests/SMS/LoggedOutGoingSMSTest.php @@ -12,10 +12,7 @@ class LoggedOutGoingSMSTest extends AbstractEnviromentProvider */ public function testIsSMSListEmpty() { - if (!$this->isCommunicatorEnabled()) { - $this->markTestSkipped("Communicator is not enabled skipping test"); - } - $sms = json_decode($this->communicator->get('api/sms/sent')); + $sms = json_decode($this->getCommunicator()->get('api/sms/sent')); $this->assertEquals([], $sms); } } |