Page MenuHomeDevCentral

ServicesTest.php
No OneTemporary

ServicesTest.php

<?php
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);
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Jul 28, 09:35 (14 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2807658
Default Alt Text
ServicesTest.php (2 KB)

Event Timeline