Code Duplication    Length = 50-51 lines in 2 locations

Test/Adapter/NexmoMessageAdapterTest.php 1 location

@@ 8-58 (lines=51) @@
5
use IrishDan\NotificationBundle\Adapter\NexmoMessageAdapter;
6
use IrishDan\NotificationBundle\Message\MessageInterface;
7
8
class NexmoMessageAdapterTest extends AdapterTestCase
9
{
10
    public function setUp()
11
    {
12
        parent::setUp();
13
        $parameters = $this->getParametersFromContainer('notification.channel.nexmo.configuration');
14
        $this->adapter = new NexmoMessageAdapter($parameters);
15
    }
16
17
    public function testFormat()
18
    {
19
        $message = $this->adapter->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->adapter->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
38
        $message = 'Hello jimBob
39
Notification message for jimBob
40
Sincerely yours,
41
NotificationBundle
42
Sent via nexmo channel.';
43
44
        $this->assertEquals($message, $messageData['body']);
45
    }
46
47
    private function assertValidDispatchData(MessageInterface $message)
48
    {
49
        $this->assertEquals('nexmo', $message->getChannel());
50
51
        $dispatchData = $message->getDispatchData();
52
        $this->assertArrayHasKey('to', $dispatchData);
53
        $this->assertArrayHasKey('from', $dispatchData);
54
55
        $this->assertEquals('+44755667788', $dispatchData['to']);
56
        $this->assertEquals('JimBob', $dispatchData['from']);
57
    }
58
}

Test/Adapter/PusherMessageAdapterTest.php 1 location

@@ 9-58 (lines=50) @@
6
use IrishDan\NotificationBundle\Message\MessageInterface;
7
8
9
class PusherMessageAdapterTest extends AdapterTestCase
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $pusherManager = $this->getService('notification.pusher_manager');
16
        $this->adapter = new PusherMessageAdapter($pusherManager);
17
    }
18
19
    public function testFormat()
20
    {
21
        $message = $this->adapter->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->adapter->format($this->notification);
33
34
        $this->assertValidDispatchData($message);
35
        $this->assertMessageDataStructure($message);
36
37
        $messageData = $message->getMessageData();
38
        $this->assertEquals('New member', $messageData['title']);
39
        $message = 'Hello jimBob
40
Notification message for jimBob
41
Sincerely yours,
42
NotificationBundle
43
Sent via pusher channel.';
44
45
        $this->assertEquals($message, $messageData['body']);
46
    }
47
48
    public function assertValidDispatchData(MessageInterface $message)
49
    {
50
        $this->assertEquals('pusher', $message->getChannel());
51
52
        $dispatchData = $message->getDispatchData();
53
        $this->assertArrayHasKey('channel', $dispatchData);
54
55
        $this->assertEquals('pusher_test_1', $dispatchData['channel']);
56
        $this->assertEquals('pusher_event', $dispatchData['event']);
57
    }
58
}