Completed
Push — master ( 096a05...24230b )
by Tomasz
06:23 queued 03:29
created

RabbitMqSendDriverTest::testSend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
rs 9.0856
c 1
b 0
f 0
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Gendoria\CommandQueueRabbitMqDriverBundle\Tests\SendDriver;
4
5
use Gendoria\CommandQueue\Command\CommandInterface;
6
use Gendoria\CommandQueueRabbitMqDriverBundle\SendDriver\RabbitMqSendDriver;
7
use JMS\Serializer\SerializerBuilder;
8
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
9
use PHPUnit_Framework_TestCase;
10
11
/**
12
 * Description of RabbitMqSendDriverTest
13
 *
14
 * @author Tomasz Struczyński <[email protected]>
15
 */
16
class RabbitMqSendDriverTest extends PHPUnit_Framework_TestCase
17
{
18
    public function testSend()
19
    {
20
        $serializer = SerializerBuilder::create()->build();
21
        $producer = $this->getMockBuilder(ProducerInterface::class)->getMock();
22
        $sendDriver = new RabbitMqSendDriver($serializer, $producer);
23
        $command = $this->getMockBuilder(CommandInterface::class)->getMock();
24
        
25
        $producer->expects($this->once())
26
            ->method('publish')
27
            ->with($serializer->serialize($command, 'json'),
28
                get_class($command),
29
                array(
30
                'application_headers' => array(
31
                    'x-class-name' => array(
32
                        'S',
33
                        get_class($command),
34
                    ),
35
                ),
36
            ))
37
            ;
38
        
39
        $sendDriver->send($command);
40
    }
41
}
42