|
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\Notification\Apns; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @covers \Jgut\Tify\Notification\Apns |
|
16
|
|
|
*/ |
|
17
|
|
|
class ApnsTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
protected $notification; |
|
20
|
|
|
|
|
21
|
|
|
public function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$service = $this->getMock('\Jgut\Tify\Service\Apns', [], [], '', false); |
|
24
|
|
|
$message = $this->getMock('\Jgut\Tify\Message\Apns', [], [], '', false); |
|
25
|
|
|
|
|
26
|
|
|
$this->notification = new Apns($service, $message); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @covers \Jgut\Tify\Notification\Apns::setService |
|
31
|
|
|
* |
|
32
|
|
|
* @expectedException \InvalidArgumentException |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testServiceSet() |
|
35
|
|
|
{ |
|
36
|
|
|
$service = $this->getMock('\Jgut\Tify\Service\Apns', [], [], '', false); |
|
37
|
|
|
$this->notification->setService($service); |
|
38
|
|
|
$this->assertEquals($service, $this->notification->getService()); |
|
39
|
|
|
|
|
40
|
|
|
$service = $this->getMock('\Jgut\Tify\Service\AbstractService', [], [], '', false); |
|
41
|
|
|
|
|
42
|
|
|
$this->notification->setService($service); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @covers \Jgut\Tify\Notification\Apns::setMessage |
|
47
|
|
|
* |
|
48
|
|
|
* @expectedException \InvalidArgumentException |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testMessageSet() |
|
51
|
|
|
{ |
|
52
|
|
|
$message = $this->getMock('\Jgut\Tify\Message\Apns', [], [], '', false); |
|
53
|
|
|
$this->notification->setMessage($message); |
|
54
|
|
|
$this->assertEquals($message, $this->notification->getMessage()); |
|
55
|
|
|
|
|
56
|
|
|
$message = $this->getMock('\Jgut\Tify\Message\AbstractMessage', [], [], '', false); |
|
57
|
|
|
|
|
58
|
|
|
$this->notification->setMessage($message); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @covers \Jgut\Tify\Notification\Apns::addRecipient |
|
63
|
|
|
* |
|
64
|
|
|
* @expectedException \InvalidArgumentException |
|
65
|
|
|
*/ |
|
66
|
|
|
public function testRecipientAdd() |
|
67
|
|
|
{ |
|
68
|
|
|
$recipient = $this->getMock('\Jgut\Tify\Recipient\Apns', [], [], '', false); |
|
69
|
|
|
$this->notification->addRecipient($recipient); |
|
70
|
|
|
$this->assertCount(1, $this->notification->getRecipients()); |
|
71
|
|
|
|
|
72
|
|
|
$recipient = $this->getMock('\Jgut\Tify\Recipient\AbstractRecipient', [], [], '', false); |
|
73
|
|
|
|
|
74
|
|
|
$this->notification->addRecipient($recipient); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|