testShouldAllowGetConsumerSetInConstructor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle\Tests\Event;
4
5
use OldSound\RabbitMqBundle\Event\OnIdleEvent;
6
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Class OnIdleEventTest
11
 *
12
 * @package OldSound\RabbitMqBundle\Tests\Event
13
 */
14
class OnIdleEventTest extends TestCase
15
{
16
    protected function getConsumer()
17
    {
18
        return new Consumer(
19
            $this->getMockBuilder('\PhpAmqpLib\Connection\AMQPStreamConnection')
20
                ->disableOriginalConstructor()
21
                ->getMock(),
22
            $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')
23
                ->disableOriginalConstructor()
24
                ->getMock()
25
        );
26
    }
27
28
    public function testShouldAllowGetConsumerSetInConstructor()
29
    {
30
        $consumer = $this->getConsumer();
31
        $event = new OnIdleEvent($consumer);
32
33
        $this->assertSame($consumer, $event->getConsumer());
34
    }
35
36
    public function testShouldSetForceStopToTrueInConstructor()
37
    {
38
        $consumer = $this->getConsumer();
39
        $event = new OnIdleEvent($consumer);
40
41
        $this->assertTrue($event->isForceStop());
42
    }
43
44
    public function testShouldReturnPreviouslySetForceStop()
45
    {
46
        $consumer = $this->getConsumer();
47
        $event = new OnIdleEvent($consumer);
48
49
        //guard
50
        $this->assertTrue($event->isForceStop());
51
52
        $event->setForceStop(false);
53
        $this->assertFalse($event->isForceStop());
54
    }
55
}
56