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

MailDataFormatterTest::assertMessageDataStructure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Formatter;
4
5
6
use IrishDan\NotificationBundle\Formatter\MailDataFormatter;
7
use IrishDan\NotificationBundle\Message\MessageInterface;
8
9 View Code Duplication
class MailDataFormatterTest 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...
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $this->formatter = new MailDataFormatter(
16
            [
17
                'default_sender' => '[email protected]',
18
            ]
19
        );
20
    }
21
22
    public function testFormat()
23
    {
24
        $message = $this->formatter->format($this->notification);
25
26
        $this->assertValidDispatchData($message);
27
        $this->assertMessageDataStructure($message);
28
29
        $this->assertBasicMessageData($message);
30
    }
31
32
    public function testFormatWithTwig()
33
    {
34
        $this->setTwig();
35
        $message = $this->formatter->format($this->notification);
36
37
        $this->assertValidDispatchData($message);
38
        $this->assertMessageDataStructure($message);
39
40
        $messageData = $message->getMessageData();
41
42
        $this->assertEquals('New member', $messageData['title']);
43
        $this->assertEquals('Mail notification message for jimBob', $messageData['body']);
44
    }
45
46
    private function assertValidDispatchData(MessageInterface $message)
47
    {
48
        $this->assertEquals('mail', $message->getChannel());
49
50
        $dispatchData = $message->getDispatchData();
51
        $this->assertArrayHasKey('to', $dispatchData);
52
        $this->assertArrayHasKey('from', $dispatchData);
53
54
        $this->assertEquals('[email protected]', $dispatchData['to']);
55
        $this->assertEquals('[email protected]', $dispatchData['from']);
56
    }
57
}