testCreateDelegatorWithName()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
rs 8.8571
cc 1
eloc 26
nc 1
nop 0
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