Completed
Push — master ( 25ba26...942c9a )
by dan
02:00
created

EventChannelTest::testDispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 12
loc 12
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Channel;
4
5
use IrishDan\NotificationBundle\Channel\EventChannel;
6
use IrishDan\NotificationBundle\Exception\MessageDispatchException;
7
use IrishDan\NotificationBundle\Test\NotificationTestCase;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9
10
class EventChannelTest extends NotificationTestCase
11
{
12
    protected $eventChannel;
13
    protected $eventDispatcher;
14
    protected $notification;
15
16
    public function setUp()
17
    {
18
        parent::setUp();
19
20
        $this->notification = $this->getNotificationWithUser();
21
22
        $this->eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)
23
            ->disableOriginalConstructor()
24
            ->getMock();
25
26
        $this->eventChannel = new EventChannel($this->eventDispatcher);
27
    }
28
29 View Code Duplication
    public function testDispatch()
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...
30
    {
31
        $this->eventDispatcher->expects($this->once())->method('dispatch');
32
33
        $dispatcher = $this->getMockDispatcher();
34
        $this->eventChannel->setDispatchers('default', $dispatcher);
35
36
        $message = $this->getTestMessage();
37
        $message->setChannel('default');
38
39
        $this->eventChannel->dispatch($message);
40
    }
41
42 View Code Duplication
    public function testDispatchWithWrongChannelKey()
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...
43
    {
44
        $dispatcher = $this->getMockDispatcher();
45
        $this->eventChannel->setDispatchers('default', $dispatcher);
46
47
        $message = $this->getTestMessage();
48
        $message->setChannel('not-default');
49
50
        $this->setExpectedException(MessageDispatchException::class);
51
52
        $this->eventChannel->dispatch($message);
53
    }
54
}
55