NexmoMessageAdapterTest::assertValidDispatchData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Adapter;
4
5
use IrishDan\NotificationBundle\Adapter\NexmoMessageAdapter;
6
use IrishDan\NotificationBundle\Message\MessageInterface;
7
8
class NexmoMessageAdapterTest extends AdapterTestCase
9
{
10
    public function setUp()
11
    {
12
        parent::setUp();
13
        $parameters = $this->getParametersFromContainer('notification.channel.nexmo.configuration');
14
        $this->adapter = new NexmoMessageAdapter();
15
        $this->adapter->setConfiguration($parameters);
16
        $this->adapter->setChannelName('nexmo');
17
    }
18
19 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...
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 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...
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
40
        $message = 'Hello jimBob
41
Notification message for jimBob
42
Sincerely yours,
43
NotificationBundle
44
Sent via nexmo channel.';
45
46
        $this->assertEquals($message, $messageData['body']);
47
    }
48
49 View Code Duplication
    private 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...
50
    {
51
        $this->assertEquals('nexmo', $message->getChannel());
52
53
        $dispatchData = $message->getDispatchData();
54
        $this->assertArrayHasKey('to', $dispatchData);
55
        $this->assertArrayHasKey('from', $dispatchData);
56
57
        $this->assertEquals('+44755667788', $dispatchData['to']);
58
        $this->assertEquals('JimBob', $dispatchData['from']);
59
    }
60
}