ConnectionFactoryTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace PamiModuleTest\Service;
4
5
use PamiModule\Service\ConnectionFactory;
6
use Zend\Stdlib\ArrayUtils;
7
use Zend\Test\Util\ModuleLoader;
8
9
class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var ModuleLoader
13
     */
14
    protected $moduleLoader;
15
16
    protected function setUp()
17
    {
18
        parent::setUp();
19
        $this->moduleLoader = new ModuleLoader(include __DIR__ . '/../../TestConfiguration.php');
20
    }
21
22
    public function testCreateService()
23
    {
24
        $configuration = [
25
            'pami_module' => [
26
                'connection' => [
27
                    'default' => [
28
                        'host' => 'local.host',
29
                        'scheme' => 'tcp://',
30
                        'port' => 123,
31
                        'username' => 'admin',
32
                        'secret' => 'foosecret',
33
                        'connect_timeout' => 123,
34
                        'read_timeout' => 123,
35
                    ],
36
                ],
37
            ],
38
        ];
39
40
        $serviceManager = $this->moduleLoader->getServiceManager();
41
        $serviceManager->setAllowOverride(true);
42
43
        $config = $serviceManager->get('config');
44
        $config = ArrayUtils::merge($config, $configuration);
45
        $serviceManager->setService('config', $config);
46
47
        $factory = new ConnectionFactory('default');
48
        $service = $factory->createService($serviceManager);
49
50
        static::assertInstanceOf('PAMI\\Client\\Impl\\ClientImpl', $service);
51
    }
52
}
53