Test Failed
Branch improve-scrutinizer (33a448)
by Ayan
02:51
created

LoggerTest::testWithWrongConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php namespace Phprest\Service\Logger;
2
3
use InvalidArgumentException;
4
use League\Container\Container;
5
use Phprest\Stub\Service\SampleConfig;
6
use PHPUnit\Framework\TestCase;
7
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
    }
53
}
54