Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F25451315
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
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
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Apr 16, 05:12 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3622875
Default Alt Text
(2 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment