ConnectionStatusDelegatorFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 39
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testCreateDelegatorWithName() 0 36 1
1
<?php
2
3
namespace PamiModuleTest\Service;
4
5
use PamiModule\Listener\ConnectionStatusListener;
6
use PamiModule\Service\ConnectionStatusDelegatorFactory;
7
8
class ConnectionStatusDelegatorFactoryTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testCreateDelegatorWithName()
11
    {
12
        $eventManager = $this->getMockBuilder('Zend\\EventManager\\EventManagerInterface')->getMock();
13
        $client = $this->getMockBuilder('PamiModule\\Service\\Client')
14
            ->disableOriginalConstructor()
15
            ->setMethods(['getEventManager'])
16
            ->getMock();
17
        $serviceLocator = $this->getMockBuilder('Zend\\ServiceManager\\ServiceManager')->getMock();
18
19
        $client->expects(static::any())
20
            ->method('getEventManager')
21
            ->willReturn($eventManager);
22
23
        $listener = $this->getMockBuilder(ConnectionStatusListener::class)
24
            ->disableOriginalConstructor()
25
            ->setMethods(['attach'])
26
            ->getMock();
27
28
        $serviceLocator->expects(static::once())
29
            ->method('get')
30
            ->with(ConnectionStatusListener::class)
31
            ->willReturn($listener);
32
33
        $listener->expects(static::once())
34
            ->method('attach')
35
            ->with($eventManager);
36
37
        $callback = function () use ($client) {
38
            return $client;
39
        };
40
41
        $delegatorFactory = new ConnectionStatusDelegatorFactory();
42
        $result = $delegatorFactory->createDelegatorWithName($serviceLocator, '', '', $callback);
43
44
        static::assertSame($client, $result);
45
    }
46
}
47