Completed
Push — master ( 0e7751...1494d2 )
by dan
02:09
created

SlackWebhookAdapterTest::testFormatWithTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Adapter;
4
5
use IrishDan\NotificationBundle\Adapter\SlackWebhookMessageAdapter;
6
use IrishDan\NotificationBundle\Message\MessageInterface;
7
8
class SlackWebhookAdapterTest extends AdapterTestCase
9
{
10
    public function setUp()
11
    {
12
        parent::setUp();
13
        $this->adapter = new SlackWebhookMessageAdapter();
14
    }
15
16
    public function testFormat()
17
    {
18
        $message = $this->adapter->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->adapter->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
        $message = 'Hello jimBob
37
Notification message for jimBob
38
Sincerely yours,
39
NotificationBundle
40
Sent via slack channel.';
41
42
        $this->assertEquals($message, $messageData['body']);
43
    }
44
45
    public function assertValidDispatchData(MessageInterface $message)
46
    {
47
        $this->assertEquals('slack', $message->getChannel());
48
49
        $dispatchData = $message->getDispatchData();
50
        $this->assertEquals('https://hooks.slack.com/services/salty/salt/1234567890',
51
            $dispatchData['webhook']);
52
    }
53
}