SlackWebhookAdapterTest::testFormatWithTwig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
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
        $this->adapter->setConfiguration([]);
15
        $this->adapter->setChannelName('slack');
16
    }
17
18 View Code Duplication
    public function testFormat()
0 ignored issues
show
Duplication introduced by
This method 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...
19
    {
20
        $message = $this->adapter->format($this->notification);
21
22
        $this->assertValidDispatchData($message);
23
        $this->assertMessageDataStructure($message);
24
25
        $this->assertBasicMessageData($message);
26
    }
27
28 View Code Duplication
    public function testFormatWithTwig()
0 ignored issues
show
Duplication introduced by
This method 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...
29
    {
30
        $this->setTwig();
31
        $message = $this->adapter->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
        $message = 'Hello jimBob
39
Notification message for jimBob
40
Sincerely yours,
41
NotificationBundle
42
Sent via slack channel.';
43
44
        $this->assertEquals($message, $messageData['body']);
45
    }
46
47
    public function assertValidDispatchData(MessageInterface $message)
48
    {
49
        $this->assertEquals('slack', $message->getChannel());
50
51
        $dispatchData = $message->getDispatchData();
52
        $this->assertEquals('https://hooks.slack.com/services/salty/salt/1234567890',
53
            $dispatchData['webhook']);
54
    }
55
}