Completed
Pull Request — master (#1)
by Daniel
12:19
created

ConnectionFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAMQPConnectionParameter() 0 6 1
A testAMQPConnectionFactory() 0 7 1
A getAMQPStreamConnectionMock() 0 8 1
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Tests\Connection;
4
5
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPConnection;
6
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPConnectionInterface;
7
use Cmobi\RabbitmqBundle\Connection\ConnectionFactory;
8
use Cmobi\RabbitmqBundle\Tests\BaseTestCase;
9
use PhpAmqpLib\Connection\AMQPStreamConnection;
10
11
12
class ConnectionFactoryTest extends BaseTestCase
13
{
14
    public function testAMQPConnectionParameter()
15
    {
16
        $class = $this->getContainer()->getParameter('cmobi_rabbitmq.connection.class');
17
18
        $this->assertTrue(is_a($class, CmobiAMQPConnectionInterface::class, true));
19
    }
20
21
    public function testAMQPConnectionFactory()
22
    {
23
        $factory = new ConnectionFactory($this->getAMQPStreamConnectionMock(), []);
24
        $connection = $factory->createConnection();
25
26
        $this->assertInstanceOf(CmobiAMQPConnectionInterface::class, $connection);
27
    }
28
29
    protected function getAMQPStreamConnectionMock()
30
    {
31
        $class = $this->getMockBuilder(CmobiAMQPConnection::class)
32
            ->disableOriginalConstructor()
33
            ->getMock();
34
35
        return $class;
36
    }
37
}