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->getMockBuilder(Message::class)->disableOriginalConstructor()->getMock(); |
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
|
|
|
/** |
49
|
|
|
* @expectedException \InvalidArgumentException |
50
|
|
|
*/ |
51
|
|
|
public function testInvalidParameter() |
52
|
|
|
{ |
53
|
|
|
$this->notification->setParameter('made-up-parameter', true); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testMessage() |
57
|
|
|
{ |
58
|
|
|
$message = $this->getMockBuilder(Message::class)->disableOriginalConstructor()->getMock(); |
59
|
|
|
$this->notification->setMessage($message); |
60
|
|
|
self::assertEquals($message, $this->notification->getMessage()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testReceivers() |
64
|
|
|
{ |
65
|
|
|
$receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); |
66
|
|
|
$this->notification->addReceiver($receiver); |
67
|
|
|
self::assertCount(2, $this->notification->getReceivers()); |
68
|
|
|
|
69
|
|
|
$this->notification->clearReceivers(); |
70
|
|
|
self::assertCount(0, $this->notification->getReceivers()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..