|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is a part of nekland youtube api package |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Nekland <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full license, take a look to the LICENSE file |
|
9
|
|
|
* on the root directory of this project |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Nekland\Tests\Api; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class VideosTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @test |
|
19
|
|
|
*/ |
|
20
|
|
|
public function shouldReturnYoutubeArrayAsJson() |
|
21
|
|
|
{ |
|
22
|
|
|
$youtube = $this->getYoutubeMock(['get' => $this->getYoutubeList()]); |
|
23
|
|
|
/** @var \Nekland\YoutubeApi\Api\Videos $videos */ |
|
24
|
|
|
$videos = $youtube->api('videos'); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertEquals($videos->listById('PLXONb89nemXsCa5-v7kO8qbLnCjG9O80f')['etag'], '"X98aQHqGvPBJLZLOiSGUHCM9jnE/DqrNg5r4X93fnTIO0si3XjQXUwY"'); |
|
27
|
|
|
$this->assertEquals($videos->getById('PLXONb89nemXsCa5-v7kO8qbLnCjG9O80f')['id'], 'DR7e0DoHZ2Y'); |
|
28
|
|
|
$this->assertEquals($videos->listBy(['id' => 'PLXONb89nemXsCa5-v7kO8qbLnCjG9O80f'])['etag'], '"X98aQHqGvPBJLZLOiSGUHCM9jnE/DqrNg5r4X93fnTIO0si3XjQXUwY"'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
public function shouldThrowExceptionIfNoItemFound() |
|
33
|
|
|
{ |
|
34
|
|
|
$youtube = $this->getYoutubeMock(['get' => '{ |
|
35
|
|
|
"kind": "youtube#videoListResponse", |
|
36
|
|
|
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/q9wh51deRpP1b7X8Nc3D-bdBxqs\"", |
|
37
|
|
|
"pageInfo": { |
|
38
|
|
|
"totalResults": 0, |
|
39
|
|
|
"resultsPerPage": 0 |
|
40
|
|
|
}, |
|
41
|
|
|
"items": [] |
|
42
|
|
|
} |
|
43
|
|
|
' |
|
44
|
|
|
]); |
|
45
|
|
|
|
|
46
|
|
|
$this->expectException('Nekland\YoutubeApi\Exception\NotFoundItemException'); |
|
47
|
|
|
|
|
48
|
|
|
$youtube->api('videos')->listById('id_that_doesnt_exists'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
private function getYoutubeList() |
|
52
|
|
|
{ |
|
53
|
|
|
return ' |
|
54
|
|
|
{ |
|
55
|
|
|
"kind": "youtube#videoListResponse", |
|
56
|
|
|
"etag": "\\"X98aQHqGvPBJLZLOiSGUHCM9jnE/DqrNg5r4X93fnTIO0si3XjQXUwY\\"", |
|
57
|
|
|
"pageInfo": { |
|
58
|
|
|
"totalResults": 1, |
|
59
|
|
|
"resultsPerPage": 1 |
|
60
|
|
|
}, |
|
61
|
|
|
"items": [ |
|
62
|
|
|
{ |
|
63
|
|
|
"kind": "youtube#video", |
|
64
|
|
|
"etag": "\\"X98aQHqGvPBJLZLOiSGUHCM9jnE/PYBJAtNy79ShJyHHToh-N89kDH4\\"", |
|
65
|
|
|
"id": "DR7e0DoHZ2Y", |
|
66
|
|
|
"snippet": { |
|
67
|
|
|
"publishedAt": "2014-02-19T18:00:04.000Z", |
|
68
|
|
|
"channelId": "UCvOGElQWhX8tyTxwzv1rKzg", |
|
69
|
|
|
"title": "Mystery Skulls - Ghost (Solidisco Remix)\u200f", |
|
70
|
|
|
"description": "ENM ● New Songs every Monday, Wednesday & Friday!\nDownload it from iTunes: http://bit.ly/1e5u2pM\n\nBecome a fan of Solidisco\nFB: https://facebook.com/solidisco\nSoundcloud: http://soundcloud.com/solidisco\n\nBecome a fan of Mystery Skulls\nFB: https://facebook.com/mysteryskulls\nSoundcloud: http://soundcloud.com/mysteryskulls\n\nFollow Warner bros. Records\nFB: http://facebook.com/WarnerBrosRecords\nYouTube: http://youtube.com/warnerbrosrecords\nhttp://warnerbrosrecords.com\n\nOriginal artwork: http://bit.ly/1bK1bge\n------------------------------------------------------------\nStay connected with us\nFB: http://on.fb.me/tWNN6B\n@epicnetwork\nGoogle+ http://google.com/+EpicNetworkMusic\nSoundcloud: http://snd.sc/1hQlDce\n------------------------------------------------------------\nTrack\'s title: Mystery Skulls - Ghost (Solidisco Remix)\u200f", |
|
71
|
|
|
"thumbnails": { |
|
72
|
|
|
"default": { |
|
73
|
|
|
"url": "https://i1.ytimg.com/vi/DR7e0DoHZ2Y/default.jpg" |
|
74
|
|
|
}, |
|
75
|
|
|
"medium": { |
|
76
|
|
|
"url": "https://i1.ytimg.com/vi/DR7e0DoHZ2Y/mqdefault.jpg" |
|
77
|
|
|
}, |
|
78
|
|
|
"high": { |
|
79
|
|
|
"url": "https://i1.ytimg.com/vi/DR7e0DoHZ2Y/hqdefault.jpg" |
|
80
|
|
|
}, |
|
81
|
|
|
"standard": { |
|
82
|
|
|
"url": "https://i1.ytimg.com/vi/DR7e0DoHZ2Y/sddefault.jpg" |
|
83
|
|
|
} |
|
84
|
|
|
}, |
|
85
|
|
|
"channelTitle": "ENM", |
|
86
|
|
|
"categoryId": "10", |
|
87
|
|
|
"liveBroadcastContent": "none" |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
] |
|
91
|
|
|
}'; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|