ConnectorTest::test_active_site()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
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
The property not_existant does not exist on Lifeboat\App. Since you implemented __get, consider adding a @property annotation.
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