Completed
Push — master ( 6b3e22...51e9c2 )
by Oleg
02:17
created

AppLoggerFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testHandlers() 0 18 1
A testServiceHandlers() 0 23 1
1
<?php
2
3
use Monolog\Handler\NoopHandler;
4
use Zend\ServiceManager\Factory\InvokableFactory;
5
use Zend\ServiceManager\ServiceManager;
6
7
class AppLoggerFactoryTest extends \Codeception\Test\Unit
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * @var \UnitTester
11
     */
12
    protected $tester;
13
14
    public function testHandlers()
15
    {
16
        $serviceManager = new ServiceManager();
17
        $serviceManager->setService('config', [
18
            'logger' => [
19
                'handlers' => [
20
                    new NoopHandler()
21
                ],
22
            ],
23
        ]);
24
25
        $loggerFactory = new \SlayerBirden\DataFlowServer\Logger\AppLoggerFactory();
26
27
        $logger = $loggerFactory($serviceManager);
28
29
        $handlers = $logger->getHandlers();
30
        $this->assertCount(1, $handlers);
31
    }
32
33
    public function testServiceHandlers()
34
    {
35
        $serviceManager = new ServiceManager();
36
        $serviceManager->setService('config', [
37
            'logger' => [
38
                'handlers' => [
39
                    NoopHandler::class
40
                ],
41
            ],
42
            'dependencies' => [
43
                'factories' => [
44
                    NoopHandler::class => InvokableFactory::class
45
                ],
46
            ],
47
        ]);
48
49
        $loggerFactory = new \SlayerBirden\DataFlowServer\Logger\AppLoggerFactory();
50
51
        $logger = $loggerFactory($serviceManager);
52
53
        $handlers = $logger->getHandlers();
54
        $this->assertCount(1, $handlers);
55
    }
56
}
57