Completed
Push — master ( cd8958...94944b )
by dan
02:07
created

assertValidDispatchData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Formatter;
4
5
use IrishDan\NotificationBundle\Message\MessageInterface;
6
use IrishDan\NotificationBundle\Test\Formatter\FormatterTestCase;
7
8 View Code Duplication
class SlackWebhookFormatterTest extends FormatterTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
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
}