| @@ 9-54 (lines=46) @@ | ||
| 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 | $parameters = $this->getParametersFromContainer('notification.channel.mail.configuration'); |
|
| 16 | $this->formatter = new MailDataFormatter($parameters); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function testFormat() |
|
| 20 | { |
|
| 21 | $message = $this->formatter->format($this->notification); |
|
| 22 | ||
| 23 | $this->assertValidDispatchData($message); |
|
| 24 | $this->assertMessageDataStructure($message); |
|
| 25 | ||
| 26 | $this->assertBasicMessageData($message); |
|
| 27 | } |
|
| 28 | ||
| 29 | public function testFormatWithTwig() |
|
| 30 | { |
|
| 31 | $this->setTwig(); |
|
| 32 | $message = $this->formatter->format($this->notification); |
|
| 33 | ||
| 34 | $this->assertValidDispatchData($message); |
|
| 35 | $this->assertMessageDataStructure($message); |
|
| 36 | ||
| 37 | $messageData = $message->getMessageData(); |
|
| 38 | ||
| 39 | $this->assertEquals('New member', $messageData['title']); |
|
| 40 | $this->assertEquals('Mail notification message for jimBob', $messageData['body']); |
|
| 41 | } |
|
| 42 | ||
| 43 | private function assertValidDispatchData(MessageInterface $message) |
|
| 44 | { |
|
| 45 | $this->assertEquals('mail', $message->getChannel()); |
|
| 46 | ||
| 47 | $dispatchData = $message->getDispatchData(); |
|
| 48 | $this->assertArrayHasKey('to', $dispatchData); |
|
| 49 | $this->assertArrayHasKey('from', $dispatchData); |
|
| 50 | ||
| 51 | $this->assertEquals('[email protected]', $dispatchData['to']); |
|
| 52 | $this->assertEquals('[email protected]', $dispatchData['from']); |
|
| 53 | } |
|
| 54 | } |
|
| @@ 8-51 (lines=44) @@ | ||
| 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 | $parameters = $this->getParametersFromContainer('notification.channel.nexmo.configuration'); |
|
| 14 | $this->formatter = new NexmoDataFormatter($parameters); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function testFormat() |
|
| 18 | { |
|
| 19 | $message = $this->formatter->format($this->notification); |
|
| 20 | ||
| 21 | $this->assertValidDispatchData($message); |
|
| 22 | $this->assertMessageDataStructure($message); |
|
| 23 | ||
| 24 | $this->assertBasicMessageData($message); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function testFormatWithTwig() |
|
| 28 | { |
|
| 29 | $this->setTwig(); |
|
| 30 | $message = $this->formatter->format($this->notification); |
|
| 31 | ||
| 32 | $this->assertValidDispatchData($message); |
|
| 33 | $this->assertMessageDataStructure($message); |
|
| 34 | ||
| 35 | $messageData = $message->getMessageData(); |
|
| 36 | $this->assertEquals('New member', $messageData['title']); |
|
| 37 | $this->assertEquals('Nexmo notification message for jimBob', $messageData['body']); |
|
| 38 | } |
|
| 39 | ||
| 40 | private function assertValidDispatchData(MessageInterface $message) |
|
| 41 | { |
|
| 42 | $this->assertEquals('nexmo', $message->getChannel()); |
|
| 43 | ||
| 44 | $dispatchData = $message->getDispatchData(); |
|
| 45 | $this->assertArrayHasKey('to', $dispatchData); |
|
| 46 | $this->assertArrayHasKey('from', $dispatchData); |
|
| 47 | ||
| 48 | $this->assertEquals('+44755667788', $dispatchData['to']); |
|
| 49 | $this->assertEquals('JimBob', $dispatchData['from']); |
|
| 50 | } |
|
| 51 | } |
|
| @@ 8-51 (lines=44) @@ | ||
| 5 | use IrishDan\NotificationBundle\Message\MessageInterface; |
|
| 6 | use IrishDan\NotificationBundle\Test\Formatter\FormatterTestCase; |
|
| 7 | ||
| 8 | class PusherDataFormatterTest extends FormatterTestCase |
|
| 9 | { |
|
| 10 | public function setUp() |
|
| 11 | { |
|
| 12 | parent::setUp(); |
|
| 13 | ||
| 14 | $pusherManager = $this->getService('notification.pusher_manager'); |
|
| 15 | $this->formatter = new PusherDataFormatter($pusherManager); |
|
| 16 | } |
|
| 17 | ||
| 18 | public function testFormat() |
|
| 19 | { |
|
| 20 | $message = $this->formatter->format($this->notification); |
|
| 21 | ||
| 22 | $this->assertValidDispatchData($message); |
|
| 23 | $this->assertMessageDataStructure($message); |
|
| 24 | ||
| 25 | $this->assertBasicMessageData($message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function testFormatWithTwig() |
|
| 29 | { |
|
| 30 | $this->setTwig(); |
|
| 31 | $message = $this->formatter->format($this->notification); |
|
| 32 | ||
| 33 | $this->assertValidDispatchData($message); |
|
| 34 | $this->assertMessageDataStructure($message); |
|
| 35 | ||
| 36 | $messageData = $message->getMessageData(); |
|
| 37 | $this->assertEquals('New member', $messageData['title']); |
|
| 38 | $this->assertEquals('Pusher notification message for jimBob', $messageData['body']); |
|
| 39 | } |
|
| 40 | ||
| 41 | public function assertValidDispatchData(MessageInterface $message) |
|
| 42 | { |
|
| 43 | $this->assertEquals('pusher', $message->getChannel()); |
|
| 44 | ||
| 45 | $dispatchData = $message->getDispatchData(); |
|
| 46 | $this->assertArrayHasKey('channel', $dispatchData); |
|
| 47 | ||
| 48 | $this->assertEquals('pusher_test_1', $dispatchData['channel']); |
|
| 49 | $this->assertEquals('pusher_event', $dispatchData['event']); |
|
| 50 | } |
|
| 51 | } |
|