1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Push notification services abstraction (http://github.com/juliangut/tify) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/juliangut/tify for the canonical source repository |
6
|
|
|
* |
7
|
|
|
* @license https://github.com/juliangut/tify/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Jgut\Tify\Tests\Notification; |
11
|
|
|
|
12
|
|
|
use Jgut\Tify\Message; |
13
|
|
|
use Jgut\Tify\Notification; |
14
|
|
|
use Jgut\Tify\Receiver\AbstractReceiver; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Notification tests. |
18
|
|
|
*/ |
19
|
|
|
class NotificationTest extends \PHPUnit_Framework_TestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var \Jgut\Tify\Message |
23
|
|
|
*/ |
24
|
|
|
protected $message; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \Jgut\Tify\Notification |
28
|
|
|
*/ |
29
|
|
|
protected $notification; |
30
|
|
|
|
31
|
|
|
public function setUp() |
32
|
|
|
{ |
33
|
|
|
$this->message = $this->getMock(Message::class, [], [], '', false); |
|
|
|
|
34
|
|
|
$receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); |
35
|
|
|
|
36
|
|
|
$this->notification = $this->getMockForAbstractClass( |
|
|
|
|
37
|
|
|
Notification::class, |
38
|
|
|
[$this->message, $receiver] |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testDefaults() |
43
|
|
|
{ |
44
|
|
|
self::assertEquals($this->message, $this->notification->getMessage()); |
45
|
|
|
self::assertCount(1, $this->notification->getReceivers()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testMessage() |
49
|
|
|
{ |
50
|
|
|
$message = $this->getMock(Message::class, [], [], '', false); |
|
|
|
|
51
|
|
|
$this->notification->setMessage($message); |
52
|
|
|
self::assertEquals($message, $this->notification->getMessage()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testReceivers() |
56
|
|
|
{ |
57
|
|
|
$receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); |
58
|
|
|
$this->notification->addReceiver($receiver); |
59
|
|
|
self::assertCount(2, $this->notification->getReceivers()); |
60
|
|
|
|
61
|
|
|
$this->notification->clearReceivers(); |
62
|
|
|
self::assertCount(0, $this->notification->getReceivers()); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.