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