PusherMessageAdapterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
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
class PusherMessageAdapterTest extends AdapterTestCase
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $pusherManager = $this->getService('notification.pusher_manager');
16
        $this->adapter = new PusherMessageAdapter($pusherManager);
17
        $this->adapter->setConfiguration([
18
            'channel_name' => 'pusher_test_',
19
            'event' => 'pusher_event',
20
        ]);
21
        $this->adapter->setChannelName('pusher');
22
    }
23
24 View Code Duplication
    public function testFormat()
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...
25
    {
26
        $message = $this->adapter->format($this->notification);
27
28
        $this->assertValidDispatchData($message);
29
        $this->assertMessageDataStructure($message);
30
31
        $this->assertBasicMessageData($message);
32
    }
33
34 View Code Duplication
    public function testFormatWithTwig()
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...
35
    {
36
        $this->setTwig();
37
        $message = $this->adapter->format($this->notification);
38
39
        $this->assertValidDispatchData($message);
40
        $this->assertMessageDataStructure($message);
41
42
        $messageData = $message->getMessageData();
43
        $this->assertEquals('New member', $messageData['title']);
44
        $message = 'Hello jimBob
45
Notification message for jimBob
46
Sincerely yours,
47
NotificationBundle
48
Sent via pusher channel.';
49
50
        $this->assertEquals($message, $messageData['body']);
51
    }
52
53 View Code Duplication
    public function assertValidDispatchData(MessageInterface $message)
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...
54
    {
55
        $this->assertEquals('pusher', $message->getChannel());
56
57
        $dispatchData = $message->getDispatchData();
58
        $this->assertArrayHasKey('channel', $dispatchData);
59
60
        $this->assertEquals('pusher_test_1', $dispatchData['channel']);
61
        $this->assertEquals('pusher_event', $dispatchData['event']);
62
    }
63
}