|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require_once 'base/PHPushbulletTestBase.php'; |
|
4
|
|
|
|
|
5
|
|
|
class LinkTest extends PHPushbulletTestBase |
|
6
|
|
|
{ |
|
7
|
|
|
/** @test */ |
|
8
|
|
|
|
|
9
|
|
|
public function it_can_push_a_link() |
|
10
|
|
|
{ |
|
11
|
|
|
$devices = [ |
|
12
|
|
|
'devices' => [ |
|
13
|
|
|
$this->getDevice('android'), |
|
14
|
|
|
$this->getDevice('chrome') |
|
15
|
|
|
], |
|
16
|
|
|
]; |
|
17
|
|
|
|
|
18
|
|
|
$response = $this->pushResponse([ |
|
19
|
|
|
'type' => 'link', |
|
20
|
|
|
'title' => 'Google', |
|
21
|
|
|
'url' => 'http://www.google.com', |
|
22
|
|
|
'body' => 'Search it', |
|
23
|
|
|
]); |
|
24
|
|
|
|
|
25
|
|
|
$this->mock([ |
|
26
|
|
|
$this->okResponse($devices), |
|
27
|
|
|
$this->okResponse($response), |
|
28
|
|
|
]); |
|
29
|
|
|
|
|
30
|
|
|
$response = $this->pushbullet->device('Chrome')->link('Google', 'http://www.google.com', 'Search it'); |
|
31
|
|
|
|
|
32
|
|
|
$this->assertInternalType('array', $response); |
|
33
|
|
|
$this->assertCount(1, $response); |
|
34
|
|
|
|
|
35
|
|
|
$first = reset($response); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertSame('link', $first['type']); |
|
38
|
|
|
$this->assertSame('Google', $first['title']); |
|
39
|
|
|
$this->assertSame('http://www.google.com', $first['url']); |
|
40
|
|
|
$this->assertSame('Search it', $first['body']); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertRequestHistory(['devices', 'pushes']); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** @test */ |
|
46
|
|
|
|
|
47
|
|
|
public function it_can_push_a_link_without_a_body() |
|
48
|
|
|
{ |
|
49
|
|
|
$devices = [ |
|
50
|
|
|
'devices' => [ |
|
51
|
|
|
$this->getDevice('android'), |
|
52
|
|
|
$this->getDevice('chrome') |
|
53
|
|
|
], |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
$response = $this->pushResponse([ |
|
57
|
|
|
'type' => 'link', |
|
58
|
|
|
'title' => 'Google', |
|
59
|
|
|
'url' => 'http://www.google.com', |
|
60
|
|
|
]); |
|
61
|
|
|
|
|
62
|
|
|
$this->mock([ |
|
63
|
|
|
$this->okResponse($devices), |
|
64
|
|
|
$this->okResponse($response), |
|
65
|
|
|
]); |
|
66
|
|
|
|
|
67
|
|
|
$response = $this->pushbullet->device('Chrome')->link('Google', 'http://www.google.com'); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertInternalType('array', $response); |
|
70
|
|
|
$this->assertCount(1, $response); |
|
71
|
|
|
|
|
72
|
|
|
$first = reset($response); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertSame('link', $first['type']); |
|
75
|
|
|
$this->assertSame('Google', $first['title']); |
|
76
|
|
|
$this->assertSame('http://www.google.com', $first['url']); |
|
77
|
|
|
|
|
78
|
|
|
$this->assertRequestHistory(['devices', 'pushes']); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|