-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathTvSeasonRepositoryTest.php
More file actions
173 lines (137 loc) · 4.65 KB
/
TvSeasonRepositoryTest.php
File metadata and controls
173 lines (137 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <michael@wtfz.net>
* @copyright (c) 2013, Michael Roterman
* @version 4.0.0
*/
namespace Tmdb\Tests\Repository;
use Tmdb\Exception\RuntimeException;
use Tmdb\Model\Tv;
class TvSeasonRepositoryTest extends TestCase
{
public const TV_ID = 3572;
public const SEASON_NUMBER = 1;
/**
* @test
*/
public function shouldLoadTvSeason()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$repository->load(self::TV_ID, self::SEASON_NUMBER);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER);
$this->assertRequestHasQueryParameters(['append_to_response' => 'credits,external_ids,images,changes,videos']);
}
/**
* @test
*/
public function shouldBeAbleToLoadTvSeasonWithTvAndSeason()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->load($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER);
$this->assertRequestHasQueryParameters(['append_to_response' => 'credits,external_ids,images,changes,videos']);
}
/**
* @test
*/
public function shouldGetCredits()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->getCredits($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER . '/credits');
}
/**
* @test
*/
public function shouldGetTranslations()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->getTranslations($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER . '/translations');
}
/**
* @test
*/
public function shouldGetExternalIds()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->getExternalIds($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER . '/external_ids');
}
/**
* @test
*/
public function shouldGetImages()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->getImages($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER . '/images');
}
/**
* @test
*/
public function shouldGetVideos()
{
$repository = $this->getRepositoryWithMockedHttpAdapter();
$tv = new Tv();
$tv->setId(self::TV_ID);
$season = new Tv\Season();
$season->setSeasonNumber(self::SEASON_NUMBER);
$repository->getVideos($tv, $season);
$this->assertLastRequestIsWithPathAndMethod('/3/tv/' . self::TV_ID . '/season/' . self::SEASON_NUMBER . '/videos');
}
/**
* @test
*/
public function shouldThrowExceptionWhenConditionsNotMet()
{
$this->expectException(RuntimeException::class);
$repository = $this->getRepositoryWithMockedHttpClient();
$tv = new Tv();
$tv->setId(self::TV_ID);
$repository->load($tv, null);
}
/**
* @test
*/
public function shouldThrowExceptionWhenConditionsNotMetAll()
{
$this->expectException(RuntimeException::class);
$repository = $this->getRepositoryWithMockedHttpClient();
$repository->load(null, null);
}
protected function getApiClass()
{
return 'Tmdb\Api\TvSeason';
}
protected function getRepositoryClass()
{
return 'Tmdb\Repository\TvSeasonRepository';
}
}