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
|
|
|
use Jgut\Tify\Result; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Notification tests. |
19
|
|
|
*/ |
20
|
|
|
class NotificationTest extends \PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \Jgut\Tify\Message |
24
|
|
|
*/ |
25
|
|
|
protected $message; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var \Jgut\Tify\Notification |
29
|
|
|
*/ |
30
|
|
|
protected $notification; |
31
|
|
|
|
32
|
|
|
public function setUp() |
33
|
|
|
{ |
34
|
|
|
$this->message = $this->getMock(Message::class, [], [], '', false); |
35
|
|
|
$receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); |
36
|
|
|
|
37
|
|
|
$this->notification = $this->getMockForAbstractClass( |
|
|
|
|
38
|
|
|
Notification::class, |
39
|
|
|
[$this->message, [$receiver]] |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testDefaults() |
44
|
|
|
{ |
45
|
|
|
self::assertEquals($this->message, $this->notification->getMessage()); |
46
|
|
|
self::assertCount(1, $this->notification->getReceivers()); |
47
|
|
|
self::assertCount(0, $this->notification->getResults()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testMessage() |
51
|
|
|
{ |
52
|
|
|
$message = $this->getMock(Message::class, [], [], '', false); |
53
|
|
|
$this->notification->setMessage($message); |
54
|
|
|
self::assertEquals($message, $this->notification->getMessage()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testReceivers() |
58
|
|
|
{ |
59
|
|
|
$receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); |
60
|
|
|
$this->notification->addReceiver($receiver); |
61
|
|
|
self::assertCount(1, $this->notification->getReceivers()); |
62
|
|
|
|
63
|
|
|
$this->notification->clearReceivers(); |
64
|
|
|
self::assertCount(0, $this->notification->getReceivers()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testResults() |
68
|
|
|
{ |
69
|
|
|
$result = new Result('aaa', new \DateTime('now', new \DateTimeZone('UTC'))); |
70
|
|
|
$this->notification->addResult($result); |
71
|
|
|
self::assertCount(1, $this->notification->getResults()); |
72
|
|
|
|
73
|
|
|
$this->notification->clearResults(); |
74
|
|
|
self::assertCount(0, $this->notification->getResults()); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
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..