Passed
Push — main ( 05477b...319ffc )
by Dylan
02:07
created

ConnectorTest::testServiceFactory()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 3
nc 4
nop 0
1
<?php
2
3
namespace Lifeboat\Tests;
4
5
use Lifeboat\App;
6
use Lifeboat\Client;
7
use Lifeboat\Exceptions\BadMethodException;
8
use Lifeboat\Exceptions\InvalidArgumentException;
9
use Lifeboat\Factory\ClassMap;
10
use Lifeboat\Utils\Utils;
11
12
class ConnectorTest extends TestCase {
13
14
    /**
15
     * @test
16
     * @covers \Lifeboat\Connector::__get
17
     */
18
    public function test_service_factory()
19
    {
20
        $client = new Client('mock', 'mock');
21
22
        foreach (ClassMap::SERVICES as $service => $class) {
23
            $this->assertInstanceOf($class, $client->$service);
24
        }
25
26
        try {
27
            $client->not_existant;
0 ignored issues
show
Bug Best Practice introduced by
The property not_existant does not exist on Lifeboat\Client. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            $this->fail('Connector::__get should have thrown an error for a service that does not exist');
29
        } catch (BadMethodException $e) {
30
            // Error should be thrown
31
        }
32
    }
33
34
    /**
35
     * @test
36
     *
37
     * @covers \Lifeboat\Connector::getSiteKey
38
     * @covers \Lifeboat\Connector::getHost
39
     * @covers \Lifeboat\Connector::setActiveSite
40
     */
41
    public function test_active_site()
42
    {
43
        $client = new Client('mock', 'mock');
44
        $client->setActiveSite('test.example', '123');
45
46
        $this->assertEquals('test.example', $client->getHost());
47
        $this->assertEquals('123', $client->getSiteKey());
48
    }
49
}
50