Completed
Push — master ( db8ff8...4137d9 )
by dan
01:59
created

testChannelDataIsPassedToAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Channel;
4
5
use IrishDan\NotificationBundle\Channel\DirectChannel;
6
use IrishDan\NotificationBundle\Test\Adapter\DummyAdapter;
7
use IrishDan\NotificationBundle\Test\NotificationTestCase;
8
9
class DirectChannelTest extends NotificationTestCase
10
{
11
    protected $notification;
12
13
    public function getChannel($adapter)
14
    {
15
        $config = [
16
            'key' => '123abc',
17
            'id' => 123456,
18
        ];
19
20
        $channelName = 'test_channel';
21
22
        return new DirectChannel($config, $channelName, $adapter);
23
    }
24
25
    public function setUp()
26
    {
27
        parent::setUp();
28
29
        $this->notification = $this->getNotificationWithUser();
30
    }
31
32
    public function testFormat()
33
    {
34
        $adapter = $this->getMockAdapter(true);
35
        $channel = $this->getChannel($adapter);
36
37
        $message = $channel->format($this->notification);
38
39
        $this->assertInstanceOf('IrishDan\NotificationBundle\Message\MessageInterface', $message);
40
    }
41
42 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...
43
    {
44
        $message = $this->getTestMessage();
45
46
        $adapter = $this->getMockAdapter(false, true);
47
        $channel = $this->getChannel($adapter);
48
49
        $dispatched = $channel->dispatch($message);
50
51
        $this->assertTrue($dispatched);
52
    }
53
54 View Code Duplication
    public function testFormatAndDispatch()
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...
55
    {
56
        $adapter = $this->getMockAdapter(true, true);
57
        $channel = $this->getChannel($adapter);
58
59
        $dispatched = $channel->formatAndDispatch($this->notification);
60
61
        $this->assertTrue($dispatched);
62
    }
63
64
    public function testChannelDataIsPassedToAdapter()
65
    {
66
        $adapter = new DummyAdapter();
67
        $this->getChannel($adapter);
68
69
        $this->assertEquals('test_channel', $adapter->getChannelName());
70
        $configuration = [
71
            'key' => '123abc',
72
            'id' => 123456,
73
        ];
74
        $this->assertEquals($configuration, $adapter->getConfiguration());
75
    }
76
}
77