Completed
Push — master ( e7a3c7...2372b5 )
by dan
02:03
created

NotificationManagerTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 86
Duplicated Lines 20.93 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 18
loc 86
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 16 1
A testSend() 9 9 1
A testSendMultiple() 9 9 1
A testSendWitData() 0 16 1
A testMarkAsRead() 0 3 1
A testMarkAllAsRead() 0 4 1
A testAllNotificationCount() 0 3 1
A testUnreadNotificationCount() 0 3 1
A testReadNotificationCount() 0 3 1
A testNotificationCount() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace IrishDan\NotificationBundle\Test;
4
5
use IrishDan\NotificationBundle\ChannelManager;
6
use IrishDan\NotificationBundle\DatabaseNotificationManager;
7
use IrishDan\NotificationBundle\NotificationManager;
8
use IrishDan\NotificationBundle\Test\Notification\TestNotification;
9
10
class NotificationManagerTest extends NotificationTestCase
11
{
12
    protected $manager;
13
    protected $channelManager;
14
    protected $databaseManager;
15
    protected $notification;
16
17
    public function setUp()
18
    {
19
        parent::setUp();
20
21
        $this->channelManager = $this->getMockBuilder(ChannelManager::class)
22
            ->disableOriginalConstructor()
23
            ->getMock();
24
25
        $this->databaseManager = $this->getMockBuilder(DatabaseNotificationManager::class)
26
            ->disableOriginalConstructor()
27
            ->getMock();
28
29
        $this->manager = new NotificationManager($this->channelManager);
30
31
        $this->notification = new TestNotification();
32
    }
33
34 View Code Duplication
    public function testSend()
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...
35
    {
36
        $recipient = $this->getTestUser();
37
38
        $this->channelManager->expects($this->once())
39
            ->method('send');
40
41
        $this->manager->send($this->notification, $recipient);
42
    }
43
44 View Code Duplication
    public function testSendMultiple()
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...
45
    {
46
        $recipient = $this->getTestUser();
47
48
        $this->channelManager->expects($this->any())
49
            ->method('send');
50
51
        $this->manager->send($this->notification, [$recipient, $recipient]);
52
    }
53
54
    public function testSendWitData()
55
    {
56
        $recipient = $this->getTestUser();
57
58
        $this->channelManager->expects($this->any())
59
            ->method('send');
60
61
        $this->manager->send($this->notification, [$recipient, $recipient], ['extra_data' => 'test_data']);
62
63
        $data = $this->notification->getDataArray();
64
65
        $this->assertArrayHasKey('body', $data);
66
        $this->assertArrayHasKey('title', $data);
67
        $this->assertArrayHasKey('extra_data', $data);
68
        $this->assertEquals('test_data', $data['extra_data']);
69
    }
70
71
    public function testMarkAsRead()
72
    {
73
    }
74
75
    public function testMarkAllAsRead()
76
    {
77
78
    }
79
80
    public function testAllNotificationCount()
81
    {
82
    }
83
84
    public function testUnreadNotificationCount()
85
    {
86
    }
87
88
    public function testReadNotificationCount(NotifiableInterface $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
    }
91
92
    public function testNotificationCount()
93
    {
94
    }
95
}