Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/Services/ServicesTest.php b/tests/Services/ServicesTest.php
new file mode 100644
index 0000000..f9b3ddc
--- /dev/null
+++ b/tests/Services/ServicesTest.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Services;
+
+use Nasqueron\Notifications\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->assertEquals(
+ $this->services->services, // This is public, so testable
+ $actualServices
+ );
+
+ foreach ($actualServices as $service) {
+ $this->assertInstanceOf(
+ 'Nasqueron\Notifications\Services\Service',
+ $service
+ );
+ }
+ }
+
+ public function testGetForGate () {
+ $actualServices = $this->services->getForGate('GitHub');
+ $this->assertGreaterThan(0, $actualServices);
+ foreach ($actualServices as $service) {
+ $this->assertInstanceOf(
+ 'Nasqueron\Notifications\Services\Service',
+ $service
+ );
+ $this->assertEquals('GitHub', $service->gate);
+ }
+ }
+
+ public function testFindServiceByDoor () {
+ // Search gives a result
+
+ $service = $this->services->findServiceByDoor('GitHub', 'Acme');
+ $this->assertInstanceOf(
+ 'Nasqueron\Notifications\Services\Service',
+ $service
+ );
+ $this->assertEquals('GitHub', $service->gate);
+ $this->assertEquals('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\Services\Service',
+ $service
+ );
+ $this->assertEquals('Phabricator', $service->gate);
+ $this->assertEquals('Acme', $service->door);
+
+ // Search doesn't give any result
+
+ $service = $this->services->findServiceByProperty(
+ 'Phabricator',
+ 'instance',
+ 'https://notfound.acme.tld'
+ );
+ $this->assertNull($service);
+ }
+
+}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Apr 16, 05:12 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3622875
Default Alt Text
(2 KB)

Event Timeline