1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Christian Gripp <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Core23\SetlistFm\Tests\Service; |
11
|
|
|
|
12
|
|
|
use Core23\SetlistFm\Builder\SetlistSearchBuilder; |
13
|
|
|
use Core23\SetlistFm\Connection\ConnectionInterface; |
14
|
|
|
use Core23\SetlistFm\Service\SetlistService; |
15
|
|
|
use PHPUnit\Framework\TestCase; |
16
|
|
|
|
17
|
|
|
class SetlistServiceTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
private $connection; |
20
|
|
|
|
21
|
|
|
protected function setUp() |
22
|
|
|
{ |
23
|
|
|
$this->connection = $this->prophesize(ConnectionInterface::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testItIsInstantiable(): void |
27
|
|
|
{ |
28
|
|
|
$service = new SetlistService($this->connection->reveal()); |
29
|
|
|
|
30
|
|
|
$this->assertNotNull($service); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testGetSetlist(): void |
34
|
|
|
{ |
35
|
|
|
$rawResponse = <<<'EOD' |
36
|
|
|
{ |
37
|
|
|
"artist" : { |
38
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
39
|
|
|
"tmid" : 735610, |
40
|
|
|
"name" : "The Beatles", |
41
|
|
|
"sortName" : "Beatles, The", |
42
|
|
|
"disambiguation" : "John, Paul, George and Ringo", |
43
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
44
|
|
|
}, |
45
|
|
|
"venue" : { |
46
|
|
|
"city" : { |
47
|
|
|
"id" : "5357527", |
48
|
|
|
"name" : "Hollywood", |
49
|
|
|
"stateCode" : "CA", |
50
|
|
|
"state" : "California", |
51
|
|
|
"coords" : { }, |
52
|
|
|
"country" : { } |
53
|
|
|
}, |
54
|
|
|
"url" : "https://www.setlist.fm/venue/compaq-center-san-jose-ca-usa-6bd6ca6e.html", |
55
|
|
|
"id" : "6bd6ca6e", |
56
|
|
|
"name" : "Compaq Center" |
57
|
|
|
}, |
58
|
|
|
"tour" : { |
59
|
|
|
"name" : "North American Tour 1964" |
60
|
|
|
}, |
61
|
|
|
"info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
62
|
|
|
"url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-hollywood-ca-63de4613.html", |
63
|
|
|
"id" : "63de4613", |
64
|
|
|
"versionId" : "7be1aaa0", |
65
|
|
|
"eventDate" : "23-08-1964", |
66
|
|
|
"lastUpdated" : "2013-10-20T05:18:08.000+0000" |
67
|
|
|
} |
68
|
|
|
EOD; |
69
|
|
|
|
70
|
|
|
$this->connection->call('setlist/63de4613') |
71
|
|
|
->willReturn(json_decode($rawResponse, true)) |
72
|
|
|
; |
73
|
|
|
|
74
|
|
|
$service = new SetlistService($this->connection->reveal()); |
75
|
|
|
$result = $service->getSetlist('63de4613'); |
76
|
|
|
|
77
|
|
|
$this->assertNotNull($result); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function testGetArtistSetlists(): void |
81
|
|
|
{ |
82
|
|
|
$rawResponse = <<<'EOD' |
83
|
|
|
{ |
84
|
|
|
"setlist" : [ { |
85
|
|
|
"artist" : { |
86
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
87
|
|
|
"tmid" : 735610, |
88
|
|
|
"name" : "The Beatles", |
89
|
|
|
"sortName" : "Beatles, The", |
90
|
|
|
"disambiguation" : "John, Paul, George and Ringo", |
91
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
92
|
|
|
}, |
93
|
|
|
"venue" : { |
94
|
|
|
"city" : { }, |
95
|
|
|
"url" : "https://www.setlist.fm/venue/compaq-center-san-jose-ca-usa-6bd6ca6e.html", |
96
|
|
|
"id" : "6bd6ca6e", |
97
|
|
|
"name" : "Compaq Center" |
98
|
|
|
}, |
99
|
|
|
"tour" : { |
100
|
|
|
"name" : "North American Tour 1964" |
101
|
|
|
}, |
102
|
|
|
"info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
103
|
|
|
"url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-hollywood-ca-63de4613.html", |
104
|
|
|
"id" : "63de4613", |
105
|
|
|
"versionId" : "7be1aaa0", |
106
|
|
|
"eventDate" : "23-08-1964", |
107
|
|
|
"lastUpdated" : "2013-10-20T05:18:08.000+0000" |
108
|
|
|
}], |
109
|
|
|
"total" : 1, |
110
|
|
|
"page" : 1, |
111
|
|
|
"itemsPerPage" : 20 |
112
|
|
|
} |
113
|
|
|
EOD; |
114
|
|
|
|
115
|
|
|
$this->connection->call('artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d/setlists', ['p' => 1]) |
116
|
|
|
->willReturn(json_decode($rawResponse, true)) |
117
|
|
|
; |
118
|
|
|
|
119
|
|
|
$service = new SetlistService($this->connection->reveal()); |
120
|
|
|
$result = $service->getArtistSetlists('b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d'); |
121
|
|
|
|
122
|
|
|
$this->assertNotNull($result); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function testGetVenueSetlists(): void |
126
|
|
|
{ |
127
|
|
|
$rawResponse = <<<'EOD' |
128
|
|
|
{ |
129
|
|
|
"setlist" : [ { |
130
|
|
|
"artist" : { |
131
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
132
|
|
|
"tmid" : 735610, |
133
|
|
|
"name" : "The Beatles", |
134
|
|
|
"sortName" : "Beatles, The", |
135
|
|
|
"disambiguation" : "John, Paul, George and Ringo", |
136
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
137
|
|
|
}, |
138
|
|
|
"venue" : { |
139
|
|
|
"city" : { }, |
140
|
|
|
"url" : "https://www.setlist.fm/venue/compaq-center-san-jose-ca-usa-6bd6ca6e.html", |
141
|
|
|
"id" : "6bd6ca6e", |
142
|
|
|
"name" : "Compaq Center" |
143
|
|
|
}, |
144
|
|
|
"tour" : { |
145
|
|
|
"name" : "North American Tour 1964" |
146
|
|
|
}, |
147
|
|
|
"info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
148
|
|
|
"url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-hollywood-ca-63de4613.html", |
149
|
|
|
"id" : "63de4613", |
150
|
|
|
"versionId" : "7be1aaa0", |
151
|
|
|
"eventDate" : "23-08-1964", |
152
|
|
|
"lastUpdated" : "2013-10-20T05:18:08.000+0000" |
153
|
|
|
}], |
154
|
|
|
"total" : 1, |
155
|
|
|
"page" : 1, |
156
|
|
|
"itemsPerPage" : 20 |
157
|
|
|
} |
158
|
|
|
EOD; |
159
|
|
|
|
160
|
|
|
$this->connection->call('venue/6bd6ca6e/setlists', ['p' => 1]) |
161
|
|
|
->willReturn(json_decode($rawResponse, true)) |
162
|
|
|
; |
163
|
|
|
|
164
|
|
|
$service = new SetlistService($this->connection->reveal()); |
165
|
|
|
$result = $service->getVenueSetlists('6bd6ca6e'); |
166
|
|
|
|
167
|
|
|
$this->assertNotNull($result); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function testGetSetlistByVersion(): void |
171
|
|
|
{ |
172
|
|
|
$rawResponse = <<<'EOD' |
173
|
|
|
{ |
174
|
|
|
"artist" : { |
175
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
176
|
|
|
"tmid" : 735610, |
177
|
|
|
"name" : "The Beatles", |
178
|
|
|
"sortName" : "Beatles, The", |
179
|
|
|
"disambiguation" : "John, Paul, George and Ringo", |
180
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
181
|
|
|
}, |
182
|
|
|
"venue" : { |
183
|
|
|
"city" : { |
184
|
|
|
"id" : "5357527", |
185
|
|
|
"name" : "Hollywood", |
186
|
|
|
"stateCode" : "CA", |
187
|
|
|
"state" : "California", |
188
|
|
|
"coords" : { }, |
189
|
|
|
"country" : { } |
190
|
|
|
}, |
191
|
|
|
"url" : "https://www.setlist.fm/venue/compaq-center-san-jose-ca-usa-6bd6ca6e.html", |
192
|
|
|
"id" : "6bd6ca6e", |
193
|
|
|
"name" : "Compaq Center" |
194
|
|
|
}, |
195
|
|
|
"tour" : { |
196
|
|
|
"name" : "North American Tour 1964" |
197
|
|
|
}, |
198
|
|
|
"info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
199
|
|
|
"url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-hollywood-ca-63de4613.html", |
200
|
|
|
"id" : "63de4613", |
201
|
|
|
"versionId" : "7be1aaa0", |
202
|
|
|
"eventDate" : "23-08-1964", |
203
|
|
|
"lastUpdated" : "2013-10-20T05:18:08.000+0000" |
204
|
|
|
} |
205
|
|
|
EOD; |
206
|
|
|
|
207
|
|
|
$this->connection->call('setlist/version/7be1aaa0') |
208
|
|
|
->willReturn(json_decode($rawResponse, true)) |
209
|
|
|
; |
210
|
|
|
|
211
|
|
|
$service = new SetlistService($this->connection->reveal()); |
212
|
|
|
$result = $service->getSetlistByVersion('7be1aaa0'); |
213
|
|
|
|
214
|
|
|
$this->assertNotNull($result); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function testSearch(): void |
218
|
|
|
{ |
219
|
|
|
$rawResponse = <<<'EOD' |
220
|
|
|
{ |
221
|
|
|
"setlist" : [ { |
222
|
|
|
"artist" : { |
223
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
224
|
|
|
"tmid" : 735610, |
225
|
|
|
"name" : "The Beatles", |
226
|
|
|
"sortName" : "Beatles, The", |
227
|
|
|
"disambiguation" : "John, Paul, George and Ringo", |
228
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
229
|
|
|
}, |
230
|
|
|
"venue" : { |
231
|
|
|
"city" : { }, |
232
|
|
|
"url" : "https://www.setlist.fm/venue/compaq-center-san-jose-ca-usa-6bd6ca6e.html", |
233
|
|
|
"id" : "6bd6ca6e", |
234
|
|
|
"name" : "Compaq Center" |
235
|
|
|
}, |
236
|
|
|
"tour" : { |
237
|
|
|
"name" : "North American Tour 1964" |
238
|
|
|
}, |
239
|
|
|
"info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
240
|
|
|
"url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-hollywood-ca-63de4613.html", |
241
|
|
|
"id" : "63de4613", |
242
|
|
|
"versionId" : "7be1aaa0", |
243
|
|
|
"eventDate" : "23-08-1964", |
244
|
|
|
"lastUpdated" : "2013-10-20T05:18:08.000+0000" |
245
|
|
|
}], |
246
|
|
|
"total" : 1, |
247
|
|
|
"page" : 1, |
248
|
|
|
"itemsPerPage" : 20 |
249
|
|
|
} |
250
|
|
|
EOD; |
251
|
|
|
|
252
|
|
|
$this->connection->call('search/setlists', ['p' => 1, 'artistName' => 'The Beatles']) |
253
|
|
|
->willReturn(json_decode($rawResponse, true)) |
254
|
|
|
; |
255
|
|
|
|
256
|
|
|
$service = new SetlistService($this->connection->reveal()); |
257
|
|
|
$result = $service->search(SetlistSearchBuilder::create() |
258
|
|
|
->withArtistName('The Beatles')); |
259
|
|
|
|
260
|
|
|
$this->assertNotNull($result); |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|