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