Completed
Pull Request — master (#1)
by Daniel
15:18 queued 11:09
created

testGetCallbackAfterBuildQueue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Tests\Rpc;
4
5
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPChannel;
6
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPConnection;
7
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPConnectionInterface;
8
use Cmobi\RabbitmqBundle\Connection\ConnectionManager;
9
use Cmobi\RabbitmqBundle\Queue\QueueCallbackInterface;
10
use Cmobi\RabbitmqBundle\Queue\QueueInterface;
11
use Cmobi\RabbitmqBundle\Queue\QueueServiceInterface;
12
use Cmobi\RabbitmqBundle\Transport\Rpc\RpcServerBuilder;
13
use Cmobi\RabbitmqBundle\Tests\BaseTestCase;
14
15
class RpcServerBuilderTest extends BaseTestCase
16
{
17 View Code Duplication
    public function testGetConnectionManager()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $rpcServer = new RpcServerBuilder($this->getConnectionManagerMock(), $this->getLoggerMock(), []);
20
        $connectionManager = $rpcServer->getConnectionManager();
21
22
        $this->assertInstanceOf(ConnectionManager::class, $connectionManager);
23
    }
24
25 View Code Duplication
    public function testBuildQueue()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $rpcServer = new RpcServerBuilder($this->getConnectionManagerMock(), $this->getLoggerMock(), []);
28
        $queue = $rpcServer->buildQueue('test', $this->getQueueServiceMock());
29
30
        $this->assertInstanceOf(QueueInterface::class, $queue);
31
    }
32
33 View Code Duplication
    public function testGetCallbackAfterBuildQueue()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $rpcServer = new RpcServerBuilder($this->getConnectionManagerMock(), $this->getLoggerMock(), []);
36
        $queue = $rpcServer->buildQueue('test', $this->getQueueServiceMock());
37
        $callback = $queue->getCallback();
38
39
        $this->assertInstanceOf(QueueCallbackInterface::class, $callback);
40
    }
41
42
    /**
43
     * @return CmobiAMQPConnectionInterface
44
     */
45 View Code Duplication
    protected function getAMQPStreamConnectionMock()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $class = $this->getMockBuilder(CmobiAMQPConnection::class)
48
            ->disableOriginalConstructor()
49
            ->getMock();
50
51
        $channelMock = $this->getMockBuilder(CmobiAMQPChannel::class)
52
            ->disableOriginalConstructor()
53
            ->getMock();
54
        $channelMock->expects($this->any())
55
            ->method('basic_qos')
56
            ->willReturn(true);
57
58
        $class->method('channel')
59
            ->willReturn($channelMock);
60
61
        return $class;
62
    }
63
64
    /**
65
     * @return ConnectionManager
66
     */
67
    protected function getConnectionManagerMock()
68
    {
69
        $connectionManagerMock = $this->getMockBuilder(ConnectionManager::class)
70
            ->disableOriginalConstructor()
71
            ->getMock();
72
73
        return $connectionManagerMock;
74
    }
75
76
    /**
77
     * @return QueueServiceInterface
78
     */
79
    protected function getQueueServiceMock()
80
    {
81
        $queueCallback = $this->getMockBuilder(QueueServiceInterface::class)
82
            ->disableOriginalConstructor()
83
            ->getMock();
84
85
        return $queueCallback;
86
    }
87
}
88