Completed
Push — master ( 40fe4a...13aa34 )
by dan
01:54
created

NexmoDataFormatterTest::testFormatWithTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
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\Formatter;
4
5
use IrishDan\NotificationBundle\Message\MessageInterface;
6
use IrishDan\NotificationBundle\Test\Formatter\FormatterTestCase;
7
8 View Code Duplication
class NexmoDataFormatterTest extends FormatterTestCase
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...
9
{
10
    public function setUp()
11
    {
12
        parent::setUp();
13
14
        $this->formatter = new NexmoDataFormatter(
15
            [
16
                'from' => 'JimBob',
17
            ]
18
        );
19
    }
20
21
    public function testFormat()
22
    {
23
        $message = $this->formatter->format($this->notification);
24
25
        $this->assertValidDispatchData($message);
26
        $this->assertMessageDataStructure($message);
27
28
        $this->assertBasicMessageData($message);
29
    }
30
31
    public function testFormatWithTwig()
32
    {
33
        $this->setTwig();
34
        $message = $this->formatter->format($this->notification);
35
36
        $this->assertValidDispatchData($message);
37
        $this->assertMessageDataStructure($message);
38
39
        $messageData = $message->getMessageData();
40
        $this->assertEquals('New member', $messageData['title']);
41
        $this->assertEquals('Nexmo notification message for jimBob', $messageData['body']);
42
    }
43
44
    private function assertValidDispatchData(MessageInterface $message)
45
    {
46
        $this->assertEquals('nexmo', $message->getChannel());
47
48
        $dispatchData = $message->getDispatchData();
49
        $this->assertArrayHasKey('to', $dispatchData);
50
        $this->assertArrayHasKey('from', $dispatchData);
51
52
        $this->assertEquals('+44755667788', $dispatchData['to']);
53
        $this->assertEquals('JimBob', $dispatchData['from']);
54
    }
55
}