RedisMessagePublisherTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testInstance() 0 4 1
A testGetExchangeName() 0 4 1
A testPublish() 0 9 1
1
<?php
2
3
namespace Dekalee\RedisSwarrot\Tests\Unit\MessagePublisher;
4
5
use Dekalee\RedisSwarrot\MessagePublisher\RedisMessagePublisher;
6
use Swarrot\Broker\Message;
7
use Swarrot\Broker\MessagePublisher\MessagePublisherInterface;
8
9
/**
10
 * Class RedisMessagePublisherTest
11
 */
12
class RedisMessagePublisherTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var RedisMessagePublisher
16
     */
17
    protected $publisher;
18
19
    protected $channel;
20
    protected $queueName;
21
22
    /**
23
     * Set up the test
24
     */
25
    public function setUp()
26
    {
27
        $this->channel = $this->prophesize('\Redis');
28
        $this->queueName = 'foo';
29
30
        $this->publisher = new RedisMessagePublisher($this->channel->reveal(), $this->queueName);
31
    }
32
33
    /**
34
     * Test instance
35
     */
36
    public function testInstance()
37
    {
38
        $this->assertInstanceOf(MessagePublisherInterface::CLASS, $this->publisher);
39
    }
40
41
    /**
42
     * Test get exchange name
43
     */
44
    public function testGetExchangeName()
45
    {
46
        $this->assertSame($this->queueName, $this->publisher->getExchangeName());
47
    }
48
49
    /**
50
     * Test publish
51
     */
52
    public function testPublish()
53
    {
54
        $message = $this->prophesize(Message::CLASS);
55
        $message->getBody()->willReturn('body');
56
57
        $this->channel->lPush('bar', 'body')->shouldBeCalled();
58
59
        $this->publisher->publish($message->reveal(), 'bar');
60
    }
61
}
62