| @@ 9-47 (lines=39) @@ | ||
| 6 | use IrishDan\NotificationBundle\Formatter\DatabaseDataFormatter; |
|
| 7 | use IrishDan\NotificationBundle\Message\MessageInterface; |
|
| 8 | ||
| 9 | class DatabaseDataFormatterTest extends FormatterTestCase |
|
| 10 | { |
|
| 11 | public function setUp() |
|
| 12 | { |
|
| 13 | parent::setUp(); |
|
| 14 | $this->formatter = new DatabaseDataFormatter(); |
|
| 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('Database notification message for jimBob', $messageData['body']); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function assertValidDispatchData(MessageInterface $message) |
|
| 41 | { |
|
| 42 | $this->assertEquals('database', $message->getChannel()); |
|
| 43 | ||
| 44 | $dispatchData = $message->getDispatchData(); |
|
| 45 | $this->assertEquals(1, $dispatchData['id']); |
|
| 46 | } |
|
| 47 | } |
|
| @@ 8-46 (lines=39) @@ | ||
| 5 | use IrishDan\NotificationBundle\Message\MessageInterface; |
|
| 6 | use IrishDan\NotificationBundle\Test\Formatter\FormatterTestCase; |
|
| 7 | ||
| 8 | class SlackWebhookFormatterTest extends FormatterTestCase |
|
| 9 | { |
|
| 10 | public function setUp() |
|
| 11 | { |
|
| 12 | parent::setUp(); |
|
| 13 | $this->formatter = new SlackWebhookFormatter(); |
|
| 14 | } |
|
| 15 | ||
| 16 | public function testFormat() |
|
| 17 | { |
|
| 18 | $message = $this->formatter->format($this->notification); |
|
| 19 | ||
| 20 | $this->assertValidDispatchData($message); |
|
| 21 | $this->assertMessageDataStructure($message); |
|
| 22 | ||
| 23 | $this->assertBasicMessageData($message); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function testFormatWithTwig() |
|
| 27 | { |
|
| 28 | $this->setTwig(); |
|
| 29 | $message = $this->formatter->format($this->notification); |
|
| 30 | ||
| 31 | $this->assertValidDispatchData($message); |
|
| 32 | $this->assertMessageDataStructure($message); |
|
| 33 | ||
| 34 | $messageData = $message->getMessageData(); |
|
| 35 | $this->assertEquals('New member', $messageData['title']); |
|
| 36 | $this->assertEquals('Slack notification message for jimBob', $messageData['body']); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function assertValidDispatchData(MessageInterface $message) |
|
| 40 | { |
|
| 41 | $this->assertEquals('slack', $message->getChannel()); |
|
| 42 | ||
| 43 | $dispatchData = $message->getDispatchData(); |
|
| 44 | $this->assertEquals('https://hooks.slack.com/services/salty/salt/1234567890', $dispatchData['webhook']); |
|
| 45 | } |
|
| 46 | } |
|