1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Xklusive\BattlenetApi\Test; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
6
|
|
|
|
7
|
|
|
class WoWTest extends TestCase |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
protected $wow; |
10
|
|
|
protected $realm = 'Arathor'; |
11
|
|
|
protected $guild = 'Rise Legacy'; |
12
|
|
|
protected $character = 'Hellodora'; |
13
|
|
|
protected $achievementId = 2144; |
14
|
|
|
protected $itemId = 18803; |
15
|
|
|
protected $itemSet = 1060; |
16
|
|
|
protected $abilityId = 640; |
17
|
|
|
protected $speciesId = 258; |
18
|
|
|
protected $petLevel = 25; |
19
|
|
|
protected $petBreedId = 5; |
20
|
|
|
protected $petQualityId = 4; |
21
|
|
|
protected $pvpBracket = '2v2'; |
22
|
|
|
protected $questId = 13146; |
23
|
|
|
protected $recipeId = 33994; |
24
|
|
|
protected $spellId = 133; |
25
|
|
|
|
26
|
|
|
public function setUp() |
27
|
|
|
{ |
28
|
|
|
parent::setUp(); |
29
|
|
|
|
30
|
|
|
$this->wow = app(\Xklusive\BattlenetApi\Services\WowService::class); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** @test */ |
34
|
|
View Code Duplication |
public function api_can_fetch_wow_achievements() |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
$response = $this->wow->getAchievement($this->achievementId); |
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
39
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
40
|
|
|
$this->assertEquals($this->achievementId, $response->get('id')); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** @test */ |
44
|
|
|
public function api_can_fetch_auction_data() |
45
|
|
|
{ |
46
|
|
|
$response = $this->wow->getAuctionDataStatus($this->realm); |
47
|
|
|
|
48
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
49
|
|
|
$this->assertArrayHasKey('files', $response->toArray()); |
50
|
|
|
$this->assertObjectHasAttribute('url', $response->get('files')[0]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** @test */ |
54
|
|
|
public function api_can_fetch_supported_bosses() |
55
|
|
|
{ |
56
|
|
|
$response = $this->wow->getBossMasterList(); |
57
|
|
|
|
58
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
59
|
|
|
$this->assertArrayHasKey('bosses', $response->toArray()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** @test */ |
63
|
|
View Code Duplication |
public function api_can_fetch_a_boss() |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
$bosses = $this->wow->getBossMasterList(); |
66
|
|
|
$bossId = collect($bosses->get('bosses'))->first()->id; |
67
|
|
|
$response = $this->wow->getBoss($bossId); |
68
|
|
|
|
69
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
70
|
|
|
$this->assertArrayHasKey('name', $response->toArray()); |
71
|
|
|
$this->assertArrayHasKey('urlSlug', $response->toArray()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** @test */ |
75
|
|
|
public function api_can_fetch_realm_leader_board() |
76
|
|
|
{ |
77
|
|
|
$response = $this->wow->getRealmLeaderboard($this->realm); |
78
|
|
|
|
79
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
80
|
|
|
$this->assertArrayHasKey('challenge', $response->toArray()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** @test */ |
84
|
|
|
public function api_can_fetch_region_leader_board() |
85
|
|
|
{ |
86
|
|
|
$response = $this->wow->getRegionLeaderboard(); |
87
|
|
|
|
88
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
89
|
|
|
$this->assertArrayHasKey('challenge', $response->toArray()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** @test */ |
93
|
|
|
public function api_can_fetch_a_character() |
94
|
|
|
{ |
95
|
|
|
$response = $this->wow->getCharacter($this->realm, $this->character); |
96
|
|
|
|
97
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
98
|
|
|
$this->assertArrayHasKey('name', $response->toArray()); |
99
|
|
|
$this->assertArrayHasKey('class', $response->toArray()); |
100
|
|
|
$this->assertArrayHasKey('race', $response->toArray()); |
101
|
|
|
$this->assertArrayHasKey('gender', $response->toArray()); |
102
|
|
|
$this->assertArrayHasKey('level', $response->toArray()); |
103
|
|
|
$this->assertEquals($this->character, $response->get('name')); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** @test */ |
107
|
|
View Code Duplication |
public function api_can_fetch_a_guild() |
|
|
|
|
108
|
|
|
{ |
109
|
|
|
$response = $this->wow->getGuild($this->realm, $this->guild); |
110
|
|
|
|
111
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
112
|
|
|
$this->assertArrayHasKey('name', $response->toArray()); |
113
|
|
|
$this->assertArrayHasKey('level', $response->toArray()); |
114
|
|
|
$this->assertArrayHasKey('side', $response->toArray()); |
115
|
|
|
$this->assertArrayHasKey('emblem', $response->toArray()); |
116
|
|
|
$this->assertEquals($this->guild, $response->get('name')); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** @test */ |
120
|
|
View Code Duplication |
public function api_can_fetch_guild_members() |
|
|
|
|
121
|
|
|
{ |
122
|
|
|
$response = $this->wow->getGuildMembers($this->realm, $this->guild); |
123
|
|
|
|
124
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
125
|
|
|
$this->assertArrayHasKey('name', $response->toArray()); |
126
|
|
|
$this->assertArrayHasKey('realm', $response->toArray()); |
127
|
|
|
$this->assertArrayHasKey('members', $response->toArray()); |
128
|
|
|
$this->assertObjectHasAttribute('character', $response->get('members')[0]); |
129
|
|
|
$this->assertEquals($this->guild, $response->get('name')); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** @test */ |
133
|
|
View Code Duplication |
public function api_can_fetch_an_item() |
|
|
|
|
134
|
|
|
{ |
135
|
|
|
$response = $this->wow->getItem($this->itemId); |
136
|
|
|
|
137
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
138
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
139
|
|
|
$this->assertEquals($this->itemId, $response->get('id')); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** @test */ |
143
|
|
View Code Duplication |
public function api_can_fetch_an_item_set() |
|
|
|
|
144
|
|
|
{ |
145
|
|
|
$response = $this->wow->getItemSet($this->itemSet); |
146
|
|
|
|
147
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
148
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
149
|
|
|
$this->assertEquals($this->itemSet, $response->get('id')); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** @test */ |
153
|
|
|
public function api_can_fetch_mount_master_list() |
154
|
|
|
{ |
155
|
|
|
// Currently not producing a proper json a result # see https://us.battle.net/forums/en/bnet/topic/20759527665#1 |
156
|
|
|
$this->assertEquals(1, 1); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** @test */ |
160
|
|
View Code Duplication |
public function api_can_fetch_pet_master_list() |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
$response = $this->wow->getPetList(); |
163
|
|
|
|
164
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
165
|
|
|
$this->assertArrayHasKey('pets', $response->toArray()); |
166
|
|
|
$this->assertObjectHasAttribute('name', $response->get('pets')[0]); |
167
|
|
|
$this->assertObjectHasAttribute('family', $response->get('pets')[0]); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** @test */ |
171
|
|
View Code Duplication |
public function api_can_fetch_pet_abilities() |
|
|
|
|
172
|
|
|
{ |
173
|
|
|
$response = $this->wow->getPetAbility($this->abilityId); |
174
|
|
|
|
175
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
176
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
177
|
|
|
$this->assertEquals($this->abilityId, $response->get('id')); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** @test */ |
181
|
|
View Code Duplication |
public function api_can_fetch_pet_species() |
|
|
|
|
182
|
|
|
{ |
183
|
|
|
$response = $this->wow->getPetSpecies($this->speciesId); |
184
|
|
|
|
185
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
186
|
|
|
$this->assertArrayHasKey('speciesId', $response->toArray()); |
187
|
|
|
$this->assertEquals($this->speciesId, $response->get('speciesId')); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** @test */ |
191
|
|
View Code Duplication |
public function api_can_fetch_pet_stats() |
|
|
|
|
192
|
|
|
{ |
193
|
|
|
$response = $this->wow->getPetStats($this->speciesId); |
194
|
|
|
|
195
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
196
|
|
|
$this->assertArrayHasKey('speciesId', $response->toArray()); |
197
|
|
|
$this->assertArrayHasKey('level', $response->toArray()); |
198
|
|
|
$this->assertArrayHasKey('breedId', $response->toArray()); |
199
|
|
|
$this->assertArrayHasKey('petQualityId', $response->toArray()); |
200
|
|
|
$this->assertEquals($this->speciesId, $response->get('speciesId')); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** @test */ |
204
|
|
|
public function api_can_fetch_pet_stats_on_specific_level() |
205
|
|
|
{ |
206
|
|
|
$response = $this->wow->getPetStats($this->speciesId, ['level' => $this->petLevel, 'breedId' => $this->petBreedId, 'qualityId' =>$this->petQualityId]); |
207
|
|
|
|
208
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
209
|
|
|
$this->assertArrayHasKey('speciesId', $response->toArray()); |
210
|
|
|
$this->assertArrayHasKey('level', $response->toArray()); |
211
|
|
|
$this->assertArrayHasKey('breedId', $response->toArray()); |
212
|
|
|
$this->assertArrayHasKey('petQualityId', $response->toArray()); |
213
|
|
|
$this->assertEquals($this->speciesId, $response->get('speciesId')); |
214
|
|
|
$this->assertEquals($this->petLevel, $response->get('level')); |
215
|
|
|
$this->assertEquals($this->petBreedId, $response->get('breedId')); |
216
|
|
|
$this->assertEquals($this->petQualityId, $response->get('petQualityId')); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** @test */ |
220
|
|
View Code Duplication |
public function api_can_fetch_pvp_leaderboards() |
|
|
|
|
221
|
|
|
{ |
222
|
|
|
$response = $this->wow->getLeaderboards($this->pvpBracket); |
223
|
|
|
|
224
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
225
|
|
|
$this->assertArrayHasKey('rows', $response->toArray()); |
226
|
|
|
$this->assertObjectHasAttribute('ranking', $response->get('rows')[0]); |
227
|
|
|
$this->assertObjectHasAttribute('rating', $response->get('rows')[0]); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** @test */ |
231
|
|
View Code Duplication |
public function api_can_fetch_quest_data() |
|
|
|
|
232
|
|
|
{ |
233
|
|
|
$response = $this->wow->getQuest($this->questId); |
234
|
|
|
|
235
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
236
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
237
|
|
|
$this->assertEquals($this->questId, $response->get('id')); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** @test */ |
241
|
|
View Code Duplication |
public function api_can_fetch_realm_status() |
|
|
|
|
242
|
|
|
{ |
243
|
|
|
$response = $this->wow->getRealmStatus(); |
244
|
|
|
|
245
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
246
|
|
|
$this->assertArrayHasKey('realms', $response->toArray()); |
247
|
|
|
$this->assertObjectHasAttribute('type', $response->get('realms')[0]); |
248
|
|
|
$this->assertObjectHasAttribute('population', $response->get('realms')[0]); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** @test */ |
252
|
|
View Code Duplication |
public function api_can_fetch_a_recipe() |
|
|
|
|
253
|
|
|
{ |
254
|
|
|
$response = $this->wow->getRecipe($this->recipeId); |
255
|
|
|
|
256
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
257
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
258
|
|
|
$this->assertEquals($this->recipeId, $response->get('id')); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** @test */ |
262
|
|
View Code Duplication |
public function api_can_fetch_a_spell() |
|
|
|
|
263
|
|
|
{ |
264
|
|
|
$response = $this->wow->getSpell($this->spellId); |
265
|
|
|
|
266
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
267
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
268
|
|
|
$this->assertEquals($this->spellId, $response->get('id')); |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** @test */ |
272
|
|
|
public function api_can_fetch_zone_master_list() |
273
|
|
|
{ |
274
|
|
|
$response = $this->wow->getZonesMasterList(); |
275
|
|
|
|
276
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
277
|
|
|
$this->assertArrayHasKey('zones', $response->toArray()); |
278
|
|
|
$this->assertObjectHasAttribute('id', $response->get('zones')[0]); |
279
|
|
|
$this->assertObjectHasAttribute('name', $response->get('zones')[0]); |
280
|
|
|
$this->assertObjectHasAttribute('expansionId', $response->get('zones')[0]); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** @test */ |
284
|
|
View Code Duplication |
public function api_can_fetch_zone_details() |
|
|
|
|
285
|
|
|
{ |
286
|
|
|
$zoneId = $this->wow->getZonesMasterList()->get('zones')[0]->id; |
287
|
|
|
$response = $this->wow->getZone($zoneId); |
288
|
|
|
|
289
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
290
|
|
|
$this->assertArrayHasKey('id', $response->toArray()); |
291
|
|
|
$this->assertEquals($zoneId, $response->get('id')); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** @test */ |
295
|
|
View Code Duplication |
public function api_can_fetch_battlegroup_data() |
|
|
|
|
296
|
|
|
{ |
297
|
|
|
$response = $this->wow->getDataBattlegroups(); |
298
|
|
|
|
299
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
300
|
|
|
$this->assertArrayHasKey('battlegroups', $response->toArray()); |
301
|
|
|
$this->assertObjectHasAttribute('name', $response->get('battlegroups')[0]); |
302
|
|
|
$this->assertObjectHasAttribute('slug', $response->get('battlegroups')[0]); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** @test */ |
306
|
|
View Code Duplication |
public function api_can_fetch_character_races() |
|
|
|
|
307
|
|
|
{ |
308
|
|
|
$response = $this->wow->getDataCharacterRaces(); |
309
|
|
|
|
310
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
311
|
|
|
$this->assertArrayHasKey('races', $response->toArray()); |
312
|
|
|
$this->assertObjectHasAttribute('id', $response->get('races')[0]); |
313
|
|
|
$this->assertObjectHasAttribute('name', $response->get('races')[0]); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** @test */ |
317
|
|
View Code Duplication |
public function api_can_fetch_character_classes() |
|
|
|
|
318
|
|
|
{ |
319
|
|
|
$response = $this->wow->getDataCharacterClasses(); |
320
|
|
|
|
321
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
322
|
|
|
$this->assertArrayHasKey('classes', $response->toArray()); |
323
|
|
|
$this->assertObjectHasAttribute('id', $response->get('classes')[0]); |
324
|
|
|
$this->assertObjectHasAttribute('name', $response->get('classes')[0]); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** @test */ |
328
|
|
View Code Duplication |
public function api_can_fetch_character_achievements_data() |
|
|
|
|
329
|
|
|
{ |
330
|
|
|
$response = $this->wow->getDataCharacterAchievements(); |
331
|
|
|
|
332
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
333
|
|
|
$this->assertArrayHasKey('achievements', $response->toArray()); |
334
|
|
|
$this->assertObjectHasAttribute('id', $response->get('achievements')[0]); |
335
|
|
|
$this->assertObjectHasAttribute('achievements', $response->get('achievements')[0]); |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** @test */ |
339
|
|
View Code Duplication |
public function api_can_fetch_guild_rewards_data() |
|
|
|
|
340
|
|
|
{ |
341
|
|
|
$response = $this->wow->getDataGuildRewards(); |
342
|
|
|
|
343
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
344
|
|
|
$this->assertArrayHasKey('rewards', $response->toArray()); |
345
|
|
|
$this->assertObjectHasAttribute('minGuildLevel', $response->get('rewards')[0]); |
346
|
|
|
$this->assertObjectHasAttribute('achievement', $response->get('rewards')[0]); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** @test */ |
350
|
|
View Code Duplication |
public function api_can_fetch_guild_perks() |
|
|
|
|
351
|
|
|
{ |
352
|
|
|
$response = $this->wow->getDataGuildPerks(); |
353
|
|
|
|
354
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
355
|
|
|
$this->assertArrayHasKey('perks', $response->toArray()); |
356
|
|
|
$this->assertObjectHasAttribute('guildLevel', $response->get('perks')[0]); |
357
|
|
|
$this->assertObjectHasAttribute('spell', $response->get('perks')[0]); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** @test */ |
361
|
|
View Code Duplication |
public function api_can_fetch_guild_achievements_data() |
|
|
|
|
362
|
|
|
{ |
363
|
|
|
$response = $this->wow->getDataGuildAchievements(); |
364
|
|
|
|
365
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
366
|
|
|
$this->assertArrayHasKey('achievements', $response->toArray()); |
367
|
|
|
$this->assertObjectHasAttribute('id', $response->get('achievements')[0]); |
368
|
|
|
$this->assertObjectHasAttribute('achievements', $response->get('achievements')[0]); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** @test */ |
372
|
|
View Code Duplication |
public function api_can_fetch_item_classes_data() |
|
|
|
|
373
|
|
|
{ |
374
|
|
|
$response = $this->wow->getDataItemClasses(); |
375
|
|
|
|
376
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
377
|
|
|
$this->assertArrayHasKey('classes', $response->toArray()); |
378
|
|
|
$this->assertObjectHasAttribute('name', $response->get('classes')[0]); |
379
|
|
|
$this->assertObjectHasAttribute('class', $response->get('classes')[0]); |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** @test */ |
383
|
|
View Code Duplication |
public function api_can_fetch_talent_data() |
|
|
|
|
384
|
|
|
{ |
385
|
|
|
$response = $this->wow->getDataTalents(); |
386
|
|
|
|
387
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
388
|
|
|
$this->assertObjectHasAttribute('specs', $response->first()); |
389
|
|
|
$this->assertObjectHasAttribute('name', $response->first()->specs[0]); |
390
|
|
|
$this->assertObjectHasAttribute('role', $response->first()->specs[0]); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** @test */ |
394
|
|
View Code Duplication |
public function api_can_fetch_pet_types_data() |
|
|
|
|
395
|
|
|
{ |
396
|
|
|
$response = $this->wow->getDataPetTypes(); |
397
|
|
|
|
398
|
|
|
$this->assertInstanceOf(Collection::class, $response); |
399
|
|
|
$this->assertArrayHasKey('petTypes', $response->toArray()); |
400
|
|
|
$this->assertObjectHasAttribute('name', $response->get('petTypes')[0]); |
401
|
|
|
$this->assertObjectHasAttribute('typeAbilityId', $response->get('petTypes')[0]); |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
|