Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php namespace Phprest\Service\Logger; |
||
8 | class LoggerTest extends TestCase |
||
9 | { |
||
10 | use Getter; |
||
11 | |||
12 | /** |
||
13 | * @var Container |
||
14 | */ |
||
15 | private $continer; |
||
16 | |||
17 | public function setUp() |
||
18 | { |
||
19 | $this->continer = new Container(); |
||
20 | } |
||
21 | |||
22 | public function testInstansiation(): void |
||
23 | { |
||
24 | $service = new Service(); |
||
25 | $service->register($this->continer, new Config('sampleLoggerName')); |
||
26 | |||
27 | $loggerService = $this->continer->get(Config::getServiceName()); |
||
28 | |||
29 | $this->assertEquals('sampleLoggerName', $loggerService->getName()); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @expectedException InvalidArgumentException |
||
34 | */ |
||
35 | public function testWithWrongConfig(): void |
||
36 | { |
||
37 | $service = new Service(); |
||
38 | $service->register($this->continer, new SampleConfig()); |
||
39 | } |
||
40 | |||
41 | public function testGetter(): void |
||
42 | { |
||
43 | $service = new Service(); |
||
44 | $service->register($this->continer, new Config('anotherLoggerName')); |
||
45 | |||
46 | $this->assertEquals('anotherLoggerName', $this->serviceLogger()->getName()); |
||
47 | } |
||
48 | |||
49 | protected function getContainer(): Container |
||
50 | { |
||
51 | return $this->continer; |
||
52 | } |
||
54 |