1 | <?php |
||
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() |
||
93 | } |
||
94 |