Completed
Push — master ( 0e7751...1494d2 )
by dan
02:09
created

PusherMessageAdapterTest::testFormatWithTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Adapter;
4
5
use IrishDan\NotificationBundle\Adapter\PusherMessageAdapter;
6
use IrishDan\NotificationBundle\Message\MessageInterface;
7
8
9 View Code Duplication
class PusherMessageAdapterTest extends AdapterTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $pusherManager = $this->getService('notification.pusher_manager');
16
        $this->adapter = new PusherMessageAdapter($pusherManager);
17
    }
18
19
    public function testFormat()
20
    {
21
        $message = $this->adapter->format($this->notification);
22
23
        $this->assertValidDispatchData($message);
24
        $this->assertMessageDataStructure($message);
25
26
        $this->assertBasicMessageData($message);
27
    }
28
29
    public function testFormatWithTwig()
30
    {
31
        $this->setTwig();
32
        $message = $this->adapter->format($this->notification);
33
34
        $this->assertValidDispatchData($message);
35
        $this->assertMessageDataStructure($message);
36
37
        $messageData = $message->getMessageData();
38
        $this->assertEquals('New member', $messageData['title']);
39
        $message = 'Hello jimBob
40
Notification message for jimBob
41
Sincerely yours,
42
NotificationBundle
43
Sent via pusher channel.';
44
45
        $this->assertEquals($message, $messageData['body']);
46
    }
47
48
    public function assertValidDispatchData(MessageInterface $message)
49
    {
50
        $this->assertEquals('pusher', $message->getChannel());
51
52
        $dispatchData = $message->getDispatchData();
53
        $this->assertArrayHasKey('channel', $dispatchData);
54
55
        $this->assertEquals('pusher_test_1', $dispatchData['channel']);
56
        $this->assertEquals('pusher_event', $dispatchData['event']);
57
    }
58
}