assertValidDispatchData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Test\Adapter;
4
5
use IrishDan\NotificationBundle\Adapter\DatabaseMessageAdapter;
6
use IrishDan\NotificationBundle\DatabaseNotificationManager;
7
use IrishDan\NotificationBundle\Message\MessageInterface;
8
9
10
class DatabaseMessageAdapterTest extends AdapterTestCase
11
{
12
    protected $databaseManager;
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
        // Mock the DB manager
18
        $this->databaseManager = $this->getMockBuilder(DatabaseNotificationManager::class)
19
            ->disableOriginalConstructor()
20
            ->getMock();
21
22
        $this->adapter = new DatabaseMessageAdapter($this->databaseManager);
23
        $this->adapter->setChannelName('database');
24
    }
25
26 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...
27
    {
28
        $message = $this->adapter->format($this->notification);
29
30
        $this->assertValidDispatchData($message);
31
        $this->assertMessageDataStructure($message);
32
33
        $this->assertBasicMessageData($message);
34
    }
35
36 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...
37
    {
38
        $this->setTwig();
39
        $message = $this->adapter->format($this->notification);
40
41
        $this->assertValidDispatchData($message);
42
        $this->assertMessageDataStructure($message);
43
44
        $messageData = $message->getMessageData();
45
        $this->assertEquals('New member', $messageData['title']);
46
        $message = 'Hello jimBob
47
Notification message for jimBob
48
Sincerely yours,
49
NotificationBundle
50
Sent via database channel.';
51
52
        $this->assertEquals($message, $messageData['body']);
53
    }
54
55 View Code Duplication
    public function assertValidDispatchData(MessageInterface $message)
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...
56
    {
57
        $this->assertEquals('database', $message->getChannel());
58
59
        $dispatchData = $message->getDispatchData();
60
        $this->assertEquals(1, $dispatchData['id']);
61
        $this->assertArrayHasKey('uuid', $dispatchData);
62
        $this->assertArrayHasKey('notifiable', $dispatchData);
63
        $this->assertArrayHasKey('type', $dispatchData);
64
    }
65
}