|
1
|
|
|
<?php |
|
2
|
|
|
namespace Chadicus\Marvel\Api\Entities; |
|
3
|
|
|
|
|
4
|
|
|
use Chadicus\Marvel\Api\Client; |
|
5
|
|
|
use Chadicus\Marvel\Api\Assets\ComicAdapter; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Unit tests for the Comic class. |
|
9
|
|
|
* |
|
10
|
|
|
* @coversDefaultClass \Chadicus\Marvel\Api\Entities\Comic |
|
11
|
|
|
* @covers ::<protected> |
|
12
|
|
|
*/ |
|
13
|
|
|
final class ComicTest extends \PHPUnit_Framework_TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Verify basic behavior of getId. |
|
17
|
|
|
* |
|
18
|
|
|
* @test |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getId() |
|
23
|
|
|
{ |
|
24
|
|
|
$input = self::getTestData(); |
|
25
|
|
|
$this->assertSame($input['id'], (new Comic($input))->getId()); |
|
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Verify basic behavior of getDigitalId. |
|
30
|
|
|
* |
|
31
|
|
|
* @test |
|
32
|
|
|
* |
|
33
|
|
|
* @return void |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getDigitalId() |
|
36
|
|
|
{ |
|
37
|
|
|
$input = self::getTestData(); |
|
38
|
|
|
$this->assertSame($input['digitalId'], (new Comic($input))->getDigitalId()); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Verify basic behavior of getTitle. |
|
43
|
|
|
* |
|
44
|
|
|
* @test |
|
45
|
|
|
* |
|
46
|
|
|
* @return void |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getTitle() |
|
49
|
|
|
{ |
|
50
|
|
|
$input = self::getTestData(); |
|
51
|
|
|
$this->assertSame($input['title'], (new Comic($input))->getTitle()); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Verify basic behavior of getIssueNumber. |
|
56
|
|
|
* |
|
57
|
|
|
* @test |
|
58
|
|
|
* |
|
59
|
|
|
* @return void |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getIssueNumber() |
|
62
|
|
|
{ |
|
63
|
|
|
$input = self::getTestData(); |
|
64
|
|
|
$this->assertSame($input['issueNumber'], (new Comic($input))->getIssueNumber()); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Verify basic behavior of getVariantDescription. |
|
69
|
|
|
* |
|
70
|
|
|
* @test |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getVariantDescription() |
|
75
|
|
|
{ |
|
76
|
|
|
$input = self::getTestData(); |
|
77
|
|
|
$this->assertSame($input['variantDescription'], (new Comic($input))->getVariantDescription()); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Verify basic behavior of getDescription. |
|
82
|
|
|
* |
|
83
|
|
|
* @test |
|
84
|
|
|
* |
|
85
|
|
|
* @return void |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getDescription() |
|
88
|
|
|
{ |
|
89
|
|
|
$input = self::getTestData(); |
|
90
|
|
|
$this->assertSame($input['description'], (new Comic($input))->getDescription()); |
|
|
|
|
|
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Verify basic behavior of getModified. |
|
95
|
|
|
* |
|
96
|
|
|
* @test |
|
97
|
|
|
* |
|
98
|
|
|
* @return void |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getModified() |
|
101
|
|
|
{ |
|
102
|
|
|
$input = self::getTestData(); |
|
103
|
|
|
$this->assertSame($input['modified'], (new Comic($input))->getModified()->format('r')); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Verify basic behavior of getIsbn. |
|
108
|
|
|
* |
|
109
|
|
|
* @test |
|
110
|
|
|
* |
|
111
|
|
|
* @return void |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getIsbn() |
|
114
|
|
|
{ |
|
115
|
|
|
$input = self::getTestData(); |
|
116
|
|
|
$this->assertSame($input['isbn'], (new Comic($input))->getIsbn()); |
|
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Verify basic behavior of getUpc. |
|
121
|
|
|
* |
|
122
|
|
|
* @test |
|
123
|
|
|
* |
|
124
|
|
|
* @return void |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getUpc() |
|
127
|
|
|
{ |
|
128
|
|
|
$input = self::getTestData(); |
|
129
|
|
|
$this->assertSame($input['upc'], (new Comic($input))->getUpc()); |
|
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Verify basic behavior of getDiamondCode. |
|
134
|
|
|
* |
|
135
|
|
|
* @test |
|
136
|
|
|
* |
|
137
|
|
|
* @return void |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getDiamondCode() |
|
140
|
|
|
{ |
|
141
|
|
|
$input = self::getTestData(); |
|
142
|
|
|
$this->assertSame($input['diamondCode'], (new Comic($input))->getDiamondCode()); |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Verify basic behavior of getEan. |
|
147
|
|
|
* |
|
148
|
|
|
* @test |
|
149
|
|
|
* |
|
150
|
|
|
* @return void |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getEan() |
|
153
|
|
|
{ |
|
154
|
|
|
$input = self::getTestData(); |
|
155
|
|
|
$this->assertSame($input['ean'], (new Comic($input))->getEan()); |
|
|
|
|
|
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Verify basic behavior of getIssn. |
|
160
|
|
|
* |
|
161
|
|
|
* @test |
|
162
|
|
|
* |
|
163
|
|
|
* @return void |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getIssn() |
|
166
|
|
|
{ |
|
167
|
|
|
$input = self::getTestData(); |
|
168
|
|
|
$this->assertSame($input['issn'], (new Comic($input))->getIssn()); |
|
|
|
|
|
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* Verify basic behavior of getFormat. |
|
173
|
|
|
* |
|
174
|
|
|
* @test |
|
175
|
|
|
* |
|
176
|
|
|
* @return void |
|
177
|
|
|
*/ |
|
178
|
|
|
public function getFormat() |
|
179
|
|
|
{ |
|
180
|
|
|
$input = self::getTestData(); |
|
181
|
|
|
$this->assertSame($input['format'], (new Comic($input))->getFormat()); |
|
|
|
|
|
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Verify basic behavior of getPageCount. |
|
186
|
|
|
* |
|
187
|
|
|
* @test |
|
188
|
|
|
* |
|
189
|
|
|
* @return void |
|
190
|
|
|
*/ |
|
191
|
|
|
public function getPageCount() |
|
192
|
|
|
{ |
|
193
|
|
|
$input = self::getTestData(); |
|
194
|
|
|
$this->assertSame($input['pageCount'], (new Comic($input))->getPageCount()); |
|
|
|
|
|
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Verify basic behavior of getTextObjects. |
|
199
|
|
|
* |
|
200
|
|
|
* @test |
|
201
|
|
|
* |
|
202
|
|
|
* @return void |
|
203
|
|
|
*/ |
|
204
|
|
|
public function getTextObjects() |
|
205
|
|
|
{ |
|
206
|
|
|
$input = self::getTestData(); |
|
207
|
|
|
$comic = new Comic($input); |
|
208
|
|
|
$this->assertSame(count($input['textObjects']), count($comic->getTextObjects())); |
|
|
|
|
|
|
209
|
|
|
foreach ($comic->getTextObjects() as $key => $textObject) { |
|
|
|
|
|
|
210
|
|
|
$this->assertSame($input['textObjects'][$key]['type'], $textObject->getType()); |
|
211
|
|
|
$this->assertSame($input['textObjects'][$key]['language'], $textObject->getLanguage()); |
|
212
|
|
|
$this->assertSame($input['textObjects'][$key]['text'], $textObject->getText()); |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* Verify basic behavior of getResourceURI. |
|
218
|
|
|
* |
|
219
|
|
|
* @test |
|
220
|
|
|
* |
|
221
|
|
|
* @return void |
|
222
|
|
|
*/ |
|
223
|
|
|
public function getResourceURI() |
|
224
|
|
|
{ |
|
225
|
|
|
$input = self::getTestData(); |
|
226
|
|
|
$this->assertSame($input['resourceURI'], (new Comic($input))->getResourceURI()); |
|
|
|
|
|
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* Verify basic behavior of getUrls. |
|
231
|
|
|
* |
|
232
|
|
|
* @test |
|
233
|
|
|
* |
|
234
|
|
|
* @return void |
|
235
|
|
|
*/ |
|
236
|
|
View Code Duplication |
public function getUrls() |
|
|
|
|
|
|
237
|
|
|
{ |
|
238
|
|
|
$input = self::getTestData(); |
|
239
|
|
|
$comic = new Comic($input); |
|
240
|
|
|
$this->assertSame(count($input['urls']), count($comic->getUrls())); |
|
|
|
|
|
|
241
|
|
|
foreach ($comic->getUrls() as $key => $url) { |
|
|
|
|
|
|
242
|
|
|
$this->assertSame($input['urls'][$key]['type'], $url->getType()); |
|
243
|
|
|
$this->assertSame($input['urls'][$key]['url'], $url->getUrl()); |
|
244
|
|
|
} |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* Verify basic behavior of getSeries. |
|
249
|
|
|
* |
|
250
|
|
|
* @test |
|
251
|
|
|
* |
|
252
|
|
|
* @return void |
|
253
|
|
|
*/ |
|
254
|
|
|
public function getSeries() |
|
255
|
|
|
{ |
|
256
|
|
|
$input = self::getTestData(); |
|
257
|
|
|
$comic = new Comic($input); |
|
258
|
|
|
$this->assertSame($input['series']['resourceURI'], $comic->getSeries()->getResourceURI()); |
|
|
|
|
|
|
259
|
|
|
$this->assertSame($input['series']['name'], $comic->getSeries()->getName()); |
|
|
|
|
|
|
260
|
|
|
$this->assertSame($input['series']['type'], $comic->getSeries()->getType()); |
|
|
|
|
|
|
261
|
|
|
$this->assertSame($input['series']['role'], $comic->getSeries()->getRole()); |
|
|
|
|
|
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Verify basic behavior of getEvents. |
|
266
|
|
|
* |
|
267
|
|
|
* @test |
|
268
|
|
|
* |
|
269
|
|
|
* @return void |
|
270
|
|
|
*/ |
|
271
|
|
View Code Duplication |
public function getEvents() |
|
|
|
|
|
|
272
|
|
|
{ |
|
273
|
|
|
$input = self::getTestData(); |
|
274
|
|
|
$comic = new Comic($input); |
|
275
|
|
|
$this->assertSame($input['events']['collectionURI'], $comic->getEvents()->getCollectionURI()); |
|
|
|
|
|
|
276
|
|
|
$this->assertSame($input['events']['available'], $comic->getEvents()->getAvailable()); |
|
|
|
|
|
|
277
|
|
|
$this->assertSame($input['events']['returned'], $comic->getEvents()->getReturned()); |
|
|
|
|
|
|
278
|
|
|
$this->assertSame(count($input['events']['items']), count($comic->getEvents()->getItems())); |
|
|
|
|
|
|
279
|
|
|
foreach ($comic->getEvents()->getItems() as $key => $item) { |
|
|
|
|
|
|
280
|
|
|
$this->assertSame($input['events']['items'][$key]['resourceURI'], $item->getResourceURI()); |
|
281
|
|
|
$this->assertSame($input['events']['items'][$key]['name'], $item->getName()); |
|
282
|
|
|
$this->assertSame($input['events']['items'][$key]['type'], $item->getType()); |
|
283
|
|
|
$this->assertSame($input['events']['items'][$key]['role'], $item->getRole()); |
|
284
|
|
|
} |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* Verify basic behavior of getStories. |
|
289
|
|
|
* |
|
290
|
|
|
* @test |
|
291
|
|
|
* |
|
292
|
|
|
* @return void |
|
293
|
|
|
*/ |
|
294
|
|
View Code Duplication |
public function getStories() |
|
|
|
|
|
|
295
|
|
|
{ |
|
296
|
|
|
$input = self::getTestData(); |
|
297
|
|
|
$comic = new Comic($input); |
|
298
|
|
|
$this->assertSame($input['stories']['collectionURI'], $comic->getStories()->getCollectionURI()); |
|
|
|
|
|
|
299
|
|
|
$this->assertSame($input['stories']['available'], $comic->getStories()->getAvailable()); |
|
|
|
|
|
|
300
|
|
|
$this->assertSame($input['stories']['returned'], $comic->getStories()->getReturned()); |
|
|
|
|
|
|
301
|
|
|
$this->assertSame(count($input['stories']['items']), count($comic->getStories()->getItems())); |
|
|
|
|
|
|
302
|
|
|
foreach ($comic->getStories()->getItems() as $key => $item) { |
|
|
|
|
|
|
303
|
|
|
$this->assertSame($input['stories']['items'][$key]['resourceURI'], $item->getResourceURI()); |
|
304
|
|
|
$this->assertSame($input['stories']['items'][$key]['name'], $item->getName()); |
|
305
|
|
|
$this->assertSame($input['stories']['items'][$key]['type'], $item->getType()); |
|
306
|
|
|
$this->assertSame($input['stories']['items'][$key]['role'], $item->getRole()); |
|
307
|
|
|
} |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* Verify basic behavior of getCreators. |
|
312
|
|
|
* |
|
313
|
|
|
* @test |
|
314
|
|
|
* |
|
315
|
|
|
* @return void |
|
316
|
|
|
*/ |
|
317
|
|
View Code Duplication |
public function getCreators() |
|
|
|
|
|
|
318
|
|
|
{ |
|
319
|
|
|
$input = self::getTestData(); |
|
320
|
|
|
$comic = new Comic($input); |
|
321
|
|
|
$this->assertSame($input['creators']['collectionURI'], $comic->getCreators()->getCollectionURI()); |
|
|
|
|
|
|
322
|
|
|
$this->assertSame($input['creators']['available'], $comic->getCreators()->getAvailable()); |
|
|
|
|
|
|
323
|
|
|
$this->assertSame($input['creators']['returned'], $comic->getCreators()->getReturned()); |
|
|
|
|
|
|
324
|
|
|
$this->assertSame(count($input['creators']['items']), count($comic->getCreators()->getItems())); |
|
|
|
|
|
|
325
|
|
|
foreach ($comic->getCreators()->getItems() as $key => $item) { |
|
|
|
|
|
|
326
|
|
|
$this->assertSame($input['creators']['items'][$key]['resourceURI'], $item->getResourceURI()); |
|
327
|
|
|
$this->assertSame($input['creators']['items'][$key]['name'], $item->getName()); |
|
328
|
|
|
$this->assertSame($input['creators']['items'][$key]['type'], $item->getType()); |
|
329
|
|
|
$this->assertSame($input['creators']['items'][$key]['role'], $item->getRole()); |
|
330
|
|
|
} |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* Verify basic behavior of getCharacters. |
|
335
|
|
|
* |
|
336
|
|
|
* @test |
|
337
|
|
|
* |
|
338
|
|
|
* @return void |
|
339
|
|
|
*/ |
|
340
|
|
View Code Duplication |
public function getCharacters() |
|
|
|
|
|
|
341
|
|
|
{ |
|
342
|
|
|
$input = self::getTestData(); |
|
343
|
|
|
$comic = new Comic($input); |
|
344
|
|
|
$this->assertSame($input['characters']['collectionURI'], $comic->getCharacters()->getCollectionURI()); |
|
|
|
|
|
|
345
|
|
|
$this->assertSame($input['characters']['available'], $comic->getCharacters()->getAvailable()); |
|
|
|
|
|
|
346
|
|
|
$this->assertSame($input['characters']['returned'], $comic->getCharacters()->getReturned()); |
|
|
|
|
|
|
347
|
|
|
$this->assertSame(count($input['characters']['items']), count($comic->getCharacters()->getItems())); |
|
|
|
|
|
|
348
|
|
|
foreach ($comic->getCharacters()->getItems() as $key => $item) { |
|
|
|
|
|
|
349
|
|
|
$this->assertSame($input['characters']['items'][$key]['resourceURI'], $item->getResourceURI()); |
|
350
|
|
|
$this->assertSame($input['characters']['items'][$key]['name'], $item->getName()); |
|
351
|
|
|
$this->assertSame($input['characters']['items'][$key]['type'], $item->getType()); |
|
352
|
|
|
$this->assertSame($input['characters']['items'][$key]['role'], $item->getRole()); |
|
353
|
|
|
} |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* Verify basic behavior of getVariants. |
|
358
|
|
|
* |
|
359
|
|
|
* @test |
|
360
|
|
|
* |
|
361
|
|
|
* @return void |
|
362
|
|
|
*/ |
|
363
|
|
View Code Duplication |
public function getVariants() |
|
|
|
|
|
|
364
|
|
|
{ |
|
365
|
|
|
$input = self::getTestData(); |
|
366
|
|
|
$comic = new Comic($input); |
|
367
|
|
|
$this->assertSame(count($input['variants']), count($comic->getVariants())); |
|
|
|
|
|
|
368
|
|
|
foreach ($comic->getVariants() as $key => $variant) { |
|
|
|
|
|
|
369
|
|
|
$this->assertSame($input['variants'][$key]['resourceURI'], $variant->getResourceURI()); |
|
370
|
|
|
$this->assertSame($input['variants'][$key]['name'], $variant->getName()); |
|
371
|
|
|
$this->assertSame($input['variants'][$key]['type'], $variant->getType()); |
|
372
|
|
|
$this->assertSame($input['variants'][$key]['role'], $variant->getRole()); |
|
373
|
|
|
} |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* Verify basic behavior of getCollections. |
|
378
|
|
|
* |
|
379
|
|
|
* @test |
|
380
|
|
|
* |
|
381
|
|
|
* @return void |
|
382
|
|
|
*/ |
|
383
|
|
View Code Duplication |
public function getCollections() |
|
|
|
|
|
|
384
|
|
|
{ |
|
385
|
|
|
$input = self::getTestData(); |
|
386
|
|
|
$comic = new Comic($input); |
|
387
|
|
|
$this->assertSame(count($input['collections']), count($comic->getCollections())); |
|
|
|
|
|
|
388
|
|
|
foreach ($comic->getCollections() as $key => $collection) { |
|
|
|
|
|
|
389
|
|
|
$this->assertSame($input['collections'][$key]['resourceURI'], $collection->getResourceURI()); |
|
390
|
|
|
$this->assertSame($input['collections'][$key]['name'], $collection->getName()); |
|
391
|
|
|
$this->assertSame($input['collections'][$key]['type'], $collection->getType()); |
|
392
|
|
|
$this->assertSame($input['collections'][$key]['role'], $collection->getRole()); |
|
393
|
|
|
} |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* Verify basic behavior of getCollectedIssues. |
|
398
|
|
|
* |
|
399
|
|
|
* @test |
|
400
|
|
|
* |
|
401
|
|
|
* @return void |
|
402
|
|
|
*/ |
|
403
|
|
View Code Duplication |
public function getCollectedIssues() |
|
|
|
|
|
|
404
|
|
|
{ |
|
405
|
|
|
$input = self::getTestData(); |
|
406
|
|
|
$comic = new Comic($input); |
|
407
|
|
|
$this->assertSame(count($input['collectedIssues']), count($comic->getCollectedIssues())); |
|
|
|
|
|
|
408
|
|
|
foreach ($comic->getCollectedIssues() as $key => $issue) { |
|
|
|
|
|
|
409
|
|
|
$this->assertSame($input['collectedIssues'][$key]['resourceURI'], $issue->getResourceURI()); |
|
410
|
|
|
$this->assertSame($input['collectedIssues'][$key]['name'], $issue->getName()); |
|
411
|
|
|
$this->assertSame($input['collectedIssues'][$key]['type'], $issue->getType()); |
|
412
|
|
|
$this->assertSame($input['collectedIssues'][$key]['role'], $issue->getRole()); |
|
413
|
|
|
} |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* Verify basic behavior of getDates. |
|
418
|
|
|
* |
|
419
|
|
|
* @test |
|
420
|
|
|
* |
|
421
|
|
|
* @return void |
|
422
|
|
|
*/ |
|
423
|
|
View Code Duplication |
public function getDates() |
|
|
|
|
|
|
424
|
|
|
{ |
|
425
|
|
|
$input = self::getTestData(); |
|
426
|
|
|
$comic = new Comic($input); |
|
427
|
|
|
$this->assertSame(count($input['dates']), count($comic->getDates())); |
|
|
|
|
|
|
428
|
|
|
foreach ($comic->getDates() as $key => $date) { |
|
|
|
|
|
|
429
|
|
|
$this->assertSame($input['dates'][$key]['date'], $date->getDate()->format('r')); |
|
430
|
|
|
$this->assertSame($input['dates'][$key]['type'], $date->getType()); |
|
431
|
|
|
} |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
|
|
/** |
|
435
|
|
|
* Verify basic behavior of getPrices. |
|
436
|
|
|
* |
|
437
|
|
|
* @test |
|
438
|
|
|
* |
|
439
|
|
|
* @return void |
|
440
|
|
|
*/ |
|
441
|
|
View Code Duplication |
public function getPrices() |
|
|
|
|
|
|
442
|
|
|
{ |
|
443
|
|
|
$input = self::getTestData(); |
|
444
|
|
|
$comic = new Comic($input); |
|
445
|
|
|
$this->assertSame(count($input['prices']), count($comic->getPrices())); |
|
|
|
|
|
|
446
|
|
|
foreach ($comic->getPrices() as $key => $date) { |
|
|
|
|
|
|
447
|
|
|
$this->assertSame($input['prices'][$key]['price'], $date->getPrice()); |
|
448
|
|
|
$this->assertSame($input['prices'][$key]['type'], $date->getType()); |
|
449
|
|
|
} |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
/** |
|
453
|
|
|
* Verify basic behavior of getThumbnail. |
|
454
|
|
|
* |
|
455
|
|
|
* @test |
|
456
|
|
|
* |
|
457
|
|
|
* @return void |
|
458
|
|
|
*/ |
|
459
|
|
|
public function getThumbnail() |
|
460
|
|
|
{ |
|
461
|
|
|
$input = self::getTestData(); |
|
462
|
|
|
$comic = new Comic($input); |
|
463
|
|
|
$this->assertSame($input['thumbnail']['path'], $comic->getThumbnail()->getPath()); |
|
|
|
|
|
|
464
|
|
|
$this->assertSame($input['thumbnail']['extension'], $comic->getThumbnail()->getExtension()); |
|
|
|
|
|
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* Verify basic behavior of getImages. |
|
469
|
|
|
* |
|
470
|
|
|
* @test |
|
471
|
|
|
* |
|
472
|
|
|
* @return void |
|
473
|
|
|
*/ |
|
474
|
|
View Code Duplication |
public function getImages() |
|
|
|
|
|
|
475
|
|
|
{ |
|
476
|
|
|
$input = self::getTestData(); |
|
477
|
|
|
$comic = new Comic($input); |
|
478
|
|
|
$this->assertSame(count($input['images']), count($comic->getImages())); |
|
|
|
|
|
|
479
|
|
|
foreach ($comic->getImages() as $key => $image) { |
|
|
|
|
|
|
480
|
|
|
$this->assertSame($input['images'][$key]['path'], $image->getPath()); |
|
481
|
|
|
$this->assertSame($input['images'][$key]['extension'], $image->getExtension()); |
|
482
|
|
|
} |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* Verify basic behavior of findAll(). |
|
487
|
|
|
* |
|
488
|
|
|
* @test |
|
489
|
|
|
* @covers ::findAll |
|
490
|
|
|
* |
|
491
|
|
|
* @return void |
|
492
|
|
|
*/ |
|
493
|
|
|
public function findAll() |
|
494
|
|
|
{ |
|
495
|
|
|
$client = new Client('not under test', 'not under test', new ComicAdapter()); |
|
496
|
|
|
$comics = Comic::findAll($client, []); |
|
497
|
|
|
|
|
498
|
|
|
$this->assertSame(5, $comics->count()); |
|
499
|
|
|
foreach ($comics as $key => $comic) { |
|
500
|
|
|
$this->assertSame($key + 1, $comic->getId()); |
|
501
|
|
|
} |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* Verify query parameters are set properly with findAll(). |
|
506
|
|
|
* |
|
507
|
|
|
* @test |
|
508
|
|
|
* @covers ::findAll |
|
509
|
|
|
* |
|
510
|
|
|
* @return void |
|
511
|
|
|
*/ |
|
512
|
|
|
public function findAllParametersSetProperly() |
|
513
|
|
|
{ |
|
514
|
|
|
$now = new \DateTime(); |
|
515
|
|
|
$toDate = new \DateTime('-2 days'); |
|
516
|
|
|
$fromDate = new \DateTime('-3 days'); |
|
517
|
|
|
$criteria = [ |
|
518
|
|
|
'noVariants' => true, |
|
519
|
|
|
'hasDigitalIssue' => false, |
|
520
|
|
|
'modifiedSince' => $now->format('r'), |
|
521
|
|
|
'series' => [2, 4, 6], |
|
522
|
|
|
'events' => [1, 3, 5], |
|
523
|
|
|
'stories' => [7, 8, 9], |
|
524
|
|
|
'characters' => [2, 3, 4], |
|
525
|
|
|
'creators' => [5, 6, 7], |
|
526
|
|
|
'toDate' => $toDate->format('r'), |
|
527
|
|
|
'fromDate' => $fromDate->format('r'), |
|
528
|
|
|
]; |
|
529
|
|
|
$adapter = new ComicAdapter(); |
|
530
|
|
|
$client = new Client('not under test', 'not under test', $adapter); |
|
531
|
|
|
$comics = Comic::findAll($client, $criteria); |
|
532
|
|
|
|
|
533
|
|
|
$comics->next(); |
|
534
|
|
|
|
|
535
|
|
|
$expectedParameters = [ |
|
536
|
|
|
'noVariants' => 'true', |
|
537
|
|
|
'hasDigitalIssue' => 'false', |
|
538
|
|
|
'modifiedSince' => $now->format('c'), |
|
539
|
|
|
'series' => '2,4,6', |
|
540
|
|
|
'events' => '1,3,5', |
|
541
|
|
|
'stories' => '7,8,9', |
|
542
|
|
|
'characters' => '2,3,4', |
|
543
|
|
|
'creators' => '5,6,7', |
|
544
|
|
|
'dateRange' => "{$fromDate->format('c')},{$toDate->format('c')}", |
|
545
|
|
|
]; |
|
546
|
|
|
|
|
547
|
|
|
foreach ($expectedParameters as $key => $value) { |
|
548
|
|
|
$this->assertSame($value, $adapter->parameters[$key]); |
|
549
|
|
|
} |
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
/** |
|
553
|
|
|
* Helper method to return test comic input data |
|
554
|
|
|
* |
|
555
|
|
|
* @return array |
|
556
|
|
|
*/ |
|
557
|
|
|
private static function getTestData() |
|
558
|
|
|
{ |
|
559
|
|
|
return [ |
|
560
|
|
|
'id' => 1, |
|
561
|
|
|
'digitalId' => 2, |
|
562
|
|
|
'title' => 'a title', |
|
563
|
|
|
'issueNumber' => '3', |
|
564
|
|
|
'variantDescription' => 'a variant description', |
|
565
|
|
|
'description' => 'a description', |
|
566
|
|
|
'modified' => 'Fri, 19 Jun 2015 15:54:05 -0400', |
|
567
|
|
|
'isbn' => 'an isbn', |
|
568
|
|
|
'upc' => 'a upc', |
|
569
|
|
|
'diamondCode' => 'a diamond code', |
|
570
|
|
|
'ean' => 'an ean', |
|
571
|
|
|
'issn' => 'an issn', |
|
572
|
|
|
'format' => 'a format', |
|
573
|
|
|
'pageCount' => 4, |
|
574
|
|
|
'textObjects' => [ |
|
575
|
|
|
[ |
|
576
|
|
|
'type' => 'a text object type', |
|
577
|
|
|
'language' => 'a language', |
|
578
|
|
|
'text' => 'a text', |
|
579
|
|
|
], |
|
580
|
|
|
], |
|
581
|
|
|
'resourceURI' => 'a resource URI', |
|
582
|
|
|
'urls' => [ |
|
583
|
|
|
[ |
|
584
|
|
|
'type' => 'a url type', |
|
585
|
|
|
'url' => 'a url', |
|
586
|
|
|
], |
|
587
|
|
|
], |
|
588
|
|
|
'series' => [ |
|
589
|
|
|
'resourceURI' => 'a series resource URI', |
|
590
|
|
|
'name' => 'a series name', |
|
591
|
|
|
'type' => 'a series type', |
|
592
|
|
|
'role' => 'a series role', |
|
593
|
|
|
], |
|
594
|
|
|
'events' => [ |
|
595
|
|
|
'available' => 1, |
|
596
|
|
|
'returned' => 1, |
|
597
|
|
|
'collectionURI' => 'an events collection uri', |
|
598
|
|
|
'items' => [ |
|
599
|
|
|
[ |
|
600
|
|
|
'resourceURI' => 'a event resource URI', |
|
601
|
|
|
'name' => 'a event name', |
|
602
|
|
|
'type' => 'a event type', |
|
603
|
|
|
'role' => 'a event role', |
|
604
|
|
|
] |
|
605
|
|
|
], |
|
606
|
|
|
], |
|
607
|
|
|
'stories' => [ |
|
608
|
|
|
'available' => 1, |
|
609
|
|
|
'returned' => 1, |
|
610
|
|
|
'collectionURI' => 'an stories collection uri', |
|
611
|
|
|
'items' => [ |
|
612
|
|
|
[ |
|
613
|
|
|
'resourceURI' => 'a story resource URI', |
|
614
|
|
|
'name' => 'a story name', |
|
615
|
|
|
'type' => 'a story type', |
|
616
|
|
|
'role' => 'a story role', |
|
617
|
|
|
] |
|
618
|
|
|
], |
|
619
|
|
|
], |
|
620
|
|
|
'creators' => [ |
|
621
|
|
|
'available' => 1, |
|
622
|
|
|
'returned' => 1, |
|
623
|
|
|
'collectionURI' => 'an creators collection uri', |
|
624
|
|
|
'items' => [ |
|
625
|
|
|
[ |
|
626
|
|
|
'resourceURI' => 'a creator resource URI', |
|
627
|
|
|
'name' => 'a creator name', |
|
628
|
|
|
'type' => 'a creator type', |
|
629
|
|
|
'role' => 'a creator role', |
|
630
|
|
|
] |
|
631
|
|
|
], |
|
632
|
|
|
], |
|
633
|
|
|
'characters' => [ |
|
634
|
|
|
'available' => 1, |
|
635
|
|
|
'returned' => 1, |
|
636
|
|
|
'collectionURI' => 'an characters collection uri', |
|
637
|
|
|
'items' => [ |
|
638
|
|
|
[ |
|
639
|
|
|
'resourceURI' => 'a character resource URI', |
|
640
|
|
|
'name' => 'a character name', |
|
641
|
|
|
'type' => 'a character type', |
|
642
|
|
|
'role' => 'a character role', |
|
643
|
|
|
] |
|
644
|
|
|
], |
|
645
|
|
|
], |
|
646
|
|
|
'variants' => [ |
|
647
|
|
|
[ |
|
648
|
|
|
'resourceURI' => 'a variant resource URI', |
|
649
|
|
|
'name' => 'a variant name', |
|
650
|
|
|
'type' => 'a variant type', |
|
651
|
|
|
'role' => 'a variant role', |
|
652
|
|
|
], |
|
653
|
|
|
], |
|
654
|
|
|
'collections' => [ |
|
655
|
|
|
[ |
|
656
|
|
|
'resourceURI' => 'a collection resource URI', |
|
657
|
|
|
'name' => 'a collection name', |
|
658
|
|
|
'type' => 'a collection type', |
|
659
|
|
|
'role' => 'a collection role', |
|
660
|
|
|
], |
|
661
|
|
|
], |
|
662
|
|
|
'collectedIssues' => [ |
|
663
|
|
|
[ |
|
664
|
|
|
'resourceURI' => 'a collected issues resource URI', |
|
665
|
|
|
'name' => 'a collected issues name', |
|
666
|
|
|
'type' => 'a collected issues type', |
|
667
|
|
|
'role' => 'a collected issues role', |
|
668
|
|
|
], |
|
669
|
|
|
], |
|
670
|
|
|
'dates' => [ |
|
671
|
|
|
[ |
|
672
|
|
|
'type' => 'a date type', |
|
673
|
|
|
'date' => 'Fri, 31 Jul 2015 08:53:11 -0400', |
|
674
|
|
|
], |
|
675
|
|
|
], |
|
676
|
|
|
'prices' => [ |
|
677
|
|
|
[ |
|
678
|
|
|
'type' => 'a price type', |
|
679
|
|
|
'price' => 1.1, |
|
680
|
|
|
], |
|
681
|
|
|
], |
|
682
|
|
|
'thumbnail' => [ |
|
683
|
|
|
'path' => 'a thumbnail path', |
|
684
|
|
|
'extension' => 'a thumbnail extension', |
|
685
|
|
|
], |
|
686
|
|
|
'images' => [ |
|
687
|
|
|
[ |
|
688
|
|
|
'path' => 'an image path', |
|
689
|
|
|
'extension' => 'an image extension', |
|
690
|
|
|
], |
|
691
|
|
|
], |
|
692
|
|
|
]; |
|
693
|
|
|
} |
|
694
|
|
|
} |
|
695
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: