@@ 9-57 (lines=49) @@ | ||
6 | use IrishDan\NotificationBundle\Formatter\MailDataFormatter; |
|
7 | use IrishDan\NotificationBundle\Message\MessageInterface; |
|
8 | ||
9 | class MailDataFormatterTest extends FormatterTestCase |
|
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 | } |
@@ 8-55 (lines=48) @@ | ||
5 | use IrishDan\NotificationBundle\Message\MessageInterface; |
|
6 | use IrishDan\NotificationBundle\Test\Formatter\FormatterTestCase; |
|
7 | ||
8 | class NexmoDataFormatterTest extends FormatterTestCase |
|
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 | } |