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() |
|
|
|
|
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() |
|
|
|
|
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) |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function testNotificationCount() |
93
|
|
|
{ |
94
|
|
|
} |
95
|
|
|
} |
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.