Completed
Push — master ( be1f89...dd7c75 )
by Artem
13:35
created

RpcClientFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 1
c 4
b 0
f 0
lcom 0
cbo 5
dl 0
loc 32
rs 10
1
<?php
2
3
namespace RabbitMqModule\Service;
4
5
use PhpAmqpLib\Connection\AbstractConnection;
6
use RabbitMqModule\RpcClient;
7
use Zend\Serializer\Adapter\AdapterInterface;
8
use Zend\ServiceManager\ServiceManager;
9
10
/**
11
 * Class RpcClientFactoryTest
12
 * @package RabbitMqModule\Service
13
 */
14
class RpcClientFactoryTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testCreateService()
17
    {
18
        $factory = new RpcClientFactory('foo');
19
        $serviceManager = new ServiceManager();
20
        $serviceManager->setService(
21
            'Configuration',
22
            [
23
                'rabbitmq_module' => [
24
                    'rpc_client' => [
25
                        'foo' => [
26
                            'connection' => 'foo',
27
                            'serializer' => 'PhpSerialize',
28
                        ],
29
                    ],
30
                ],
31
            ]
32
        );
33
34
        $connection = static::getMockBuilder(AbstractConnection::class)
35
            ->disableOriginalConstructor()
36
            ->getMockForAbstractClass();
37
        $serviceManager->setService('rabbitmq_module.connection.foo', $connection);
38
39
        /** @var RpcClient $service */
40
        $service = $factory($serviceManager, 'temp');
41
42
        static::assertInstanceOf(RpcClient::class, $service);
43
        static::assertInstanceOf(AdapterInterface::class, $service->getSerializer());
44
    }
45
}
46