1<?php
2/**
3 * This file is part of the Tmdb PHP API created by Michael Roterman.
4 *
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @package Tmdb
9 * @author Michael Roterman <michael@wtfz.net>
10 * @copyright (c) 2013, Michael Roterman
11 * @version 0.0.1
12 */
13namespace Tmdb\Tests\Repository;
14
15class GenreRepositoryTest extends TestCase
16{
17    const GENRE_ID = 28;
18
19    /**
20     * @test
21     */
22    public function shouldLoadGenre()
23    {
24        $repository = $this->getRepositoryWithMockedHttpAdapter();
25
26        $this->getAdapter()->expects($this->at(0))
27            ->method('get')
28            ->with($this->getRequest('https://api.themoviedb.org/3/genre/movie/list', []))
29        ;
30
31        $this->getAdapter()->expects($this->at(1))
32            ->method('get')
33            ->with($this->getRequest('https://api.themoviedb.org/3/genre/tv/list', []))
34        ;
35
36        $repository->load(self::GENRE_ID);
37    }
38
39    /**
40     * @test
41     */
42    public function shouldLoadCollection()
43    {
44        $repository = $this->getRepositoryWithMockedHttpAdapter();
45
46        $this->getAdapter()->expects($this->at(0))
47            ->method('get')
48            ->with($this->getRequest('https://api.themoviedb.org/3/genre/movie/list', []))
49        ;
50
51        $this->getAdapter()->expects($this->at(1))
52            ->method('get')
53            ->with($this->getRequest('https://api.themoviedb.org/3/genre/tv/list', []))
54        ;
55
56        $repository->loadCollection();
57    }
58
59    /**
60     * @test
61     */
62    public function shouldLoadMovieCollection()
63    {
64        $repository = $this->getRepositoryWithMockedHttpAdapter();
65
66        $this->getAdapter()->expects($this->once())
67            ->method('get')
68            ->with($this->getRequest('https://api.themoviedb.org/3/genre/movie/list', []))
69        ;
70
71        $repository->loadMovieCollection();
72    }
73
74    /**
75     * @test
76     */
77    public function shouldLoadTvCollection()
78    {
79        $repository = $this->getRepositoryWithMockedHttpAdapter();
80
81        $this->getAdapter()->expects($this->once())
82            ->method('get')
83            ->with($this->getRequest('https://api.themoviedb.org/3/genre/tv/list', []))
84        ;
85
86        $repository->loadTvCollection();
87    }
88
89    /**
90     * @test
91     */
92    public function shouldGetMovies()
93    {
94        $repository = $this->getRepositoryWithMockedHttpAdapter();
95
96        $this->getAdapter()->expects($this->once())
97            ->method('get')
98            ->with($this->getRequest('https://api.themoviedb.org/3/genre/' . self::GENRE_ID . '/movies', []))
99        ;
100
101        $repository->getMovies(self::GENRE_ID);
102    }
103
104    /**
105     * @test
106     */
107    public function shouldGetFactory()
108    {
109        $repository = $this->getRepositoryWithMockedHttpClient();
110
111        $this->assertInstanceOf('Tmdb\Factory\GenreFactory', $repository->getFactory());
112    }
113
114    protected function getApiClass()
115    {
116        return 'Tmdb\Api\Genres';
117    }
118
119    protected function getRepositoryClass()
120    {
121        return 'Tmdb\Repository\GenreRepository';
122    }
123}
124