lifeboat-app /
php-sdk
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Lifeboat\Tests; |
||
| 4 | |||
| 5 | use Lifeboat\App; |
||
| 6 | use Lifeboat\Exceptions\BadMethodException; |
||
| 7 | use Lifeboat\Factory\ClassMap; |
||
| 8 | |||
| 9 | class ConnectorTest extends TestCase { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @test |
||
| 13 | * @covers \Lifeboat\Connector::__get |
||
| 14 | */ |
||
| 15 | public function test_service_factory() |
||
| 16 | { |
||
| 17 | $client = new App('mock', 'mock'); |
||
| 18 | |||
| 19 | foreach (ClassMap::SERVICES as $service => $class) { |
||
| 20 | $this->assertInstanceOf($class, $client->$service); |
||
| 21 | } |
||
| 22 | |||
| 23 | try { |
||
| 24 | $client->not_existant; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 25 | $this->fail('Connector::__get should have thrown an error for a service that does not exist'); |
||
| 26 | } catch (BadMethodException $e) { |
||
| 27 | // Error should be thrown |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @test |
||
| 33 | * |
||
| 34 | * @covers \Lifeboat\Connector::getSiteKey |
||
| 35 | * @covers \Lifeboat\Connector::getHost |
||
| 36 | * @covers \Lifeboat\Connector::setActiveSite |
||
| 37 | */ |
||
| 38 | public function test_active_site() |
||
| 39 | { |
||
| 40 | $client = new App('mock', 'mock'); |
||
| 41 | $client->setActiveSite('test.example', '123'); |
||
| 42 | |||
| 43 | $this->assertEquals('test.example', $client->getHost()); |
||
| 44 | $this->assertEquals('123', $client->getSiteKey()); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |