diff --git a/tests/FeaturesTest.php b/tests/Config/FeaturesTest.php similarity index 89% rename from tests/FeaturesTest.php rename to tests/Config/FeaturesTest.php index cbf85f2..70190d0 100644 --- a/tests/FeaturesTest.php +++ b/tests/Config/FeaturesTest.php @@ -1,28 +1,29 @@ <?php -namespace Nasqueron\Notifications\Tests; +namespace Nasqueron\Notifications\Tests\Config; use Nasqueron\Notifications\Config\Features; +use Nasqueron\Notifications\Tests\TestCase; class FeaturesTest extends TestCase { public function testEnable () { // Find it (en vain …) $this->assertNotContains('Quux', Features::getEnabled()); $this->assertFalse(Features::isEnabled('Quux')); // Enable it Features::enable('Quux'); $this->assertTrue(Features::isEnabled('Quux')); $this->assertContains('Quux', Features::getEnabled()); // Disable it Features::disable('Quux'); $this->assertFalse(Features::isEnabled('Quux')); // Count it $this->assertContains('Quux', Features::getAll()); $this->assertContains('Quux', Features::getAvailable()); $this->assertNotContains('Quux', Features::getEnabled()); } } diff --git a/tests/Services/ServiceTest.php b/tests/Config/Services/ServiceTest.php similarity index 94% rename from tests/Services/ServiceTest.php rename to tests/Config/Services/ServiceTest.php index 85b1971..eeff34b 100644 --- a/tests/Services/ServiceTest.php +++ b/tests/Config/Services/ServiceTest.php @@ -1,45 +1,45 @@ <?php -namespace Nasqueron\Notifications\Tests\Services; +namespace Nasqueron\Notifications\Tests\Config\Services; use Nasqueron\Notifications\Config\Services\Service; use Nasqueron\Notifications\Tests\TestCase; class ServiceTest extends TestCase { /** * @var \Nasqueron\Notifications\Config\Services\Service */ private $serviceWithInstance; /** * @var \Nasqueron\Notifications\Config\Services\Service */ private $serviceWithoutInstance; public function setUp () { $this->serviceWithoutInstance = new Service(); $this->serviceWithInstance = clone $this->serviceWithoutInstance; $this->serviceWithInstance->instance = "http://www.perdu.com"; } /// /// Tests for getInstanceName() /// public function testGetInstanceName () { $this->assertSame( "http://www.perdu.com", $this->serviceWithInstance->getInstanceName() ); } public function testGetInstanceNameWhenThereIsNoInstance () { $this->assertSame( "ø", $this->serviceWithoutInstance->getInstanceName() ); } } diff --git a/tests/Services/ServicesTest.php b/tests/Config/Services/ServicesTest.php similarity index 97% rename from tests/Services/ServicesTest.php rename to tests/Config/Services/ServicesTest.php index d996306..ecb5901 100644 --- a/tests/Services/ServicesTest.php +++ b/tests/Config/Services/ServicesTest.php @@ -1,90 +1,90 @@ <?php -namespace Nasqueron\Notifications\Tests\Services; +namespace Nasqueron\Notifications\Tests\Config\Services; use Nasqueron\Notifications\Config\Services\Services; use Nasqueron\Notifications\Tests\TestCase; class ServicesTest extends TestCase { private $services; public function setUp () { parent::setUp(); $this->services = Services::loadFromJson('credentials.json'); } public function testGet () { $actualServices = $this->services->get(); $this->assertGreaterThan(0, $actualServices); $this->assertSame( $this->services->services, // This is public, so testable $actualServices ); foreach ($actualServices as $service) { $this->assertInstanceOf( 'Nasqueron\Notifications\Config\Services\Service', $service ); } } public function testGetForGate () { $actualServices = $this->services->getForGate('GitHub'); $this->assertGreaterThan(0, $actualServices); foreach ($actualServices as $service) { $this->assertInstanceOf( 'Nasqueron\Notifications\Config\Services\Service', $service ); $this->assertSame('GitHub', $service->gate); } } public function testFindServiceByDoor () { // Search gives a result $service = $this->services->findServiceByDoor('GitHub', 'Acme'); $this->assertInstanceOf( 'Nasqueron\Notifications\Config\Services\Service', $service ); $this->assertSame('GitHub', $service->gate); $this->assertSame('Acme', $service->door); // Search doesn't give any result $service = $this->services->findServiceByDoor('GitHub', 'Quux'); $this->assertNull($service); } public function testFindServiceByProperty () { // Search gives a result $service = $this->services->findServiceByProperty( 'Phabricator', 'instance', 'https://phabricator.acme.tld' ); $this->assertInstanceOf( 'Nasqueron\Notifications\Config\Services\Service', $service ); $this->assertSame('Phabricator', $service->gate); $this->assertSame('Acme', $service->door); // Search doesn't give any result $service = $this->services->findServiceByProperty( 'Phabricator', 'instance', 'https://notfound.acme.tld' ); $this->assertNull($service); } }