public function testGetRealmNA() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once(); $this->client->shouldReceive('request')->with('v1.2/realm', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/realm.json')); $api = new Api('key', $this->client); $na = $api->staticData()->getRealm(); $this->assertEquals('en_US', $na->l); }
public function testGetRuneAll() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/na/')->once(); $this->client->shouldReceive('request')->with('v1.2/rune', ['api_key' => 'key', 'runeListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/rune.all.json')); $api = new Api('key', $this->client); $runes = $api->staticData()->getRunes('all'); $rune = $runes->getRune(5001); $this->assertEquals('0.525', $rune->stats->FlatPhysicalDamageMod); }
public function testGetMasteryAll() { $this->client->shouldReceive('baseUrl')->once(); $this->client->shouldReceive('request')->with('na/v1.2/mastery', ['api_key' => 'key', 'masteryListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.all.json')); $api = new Api('key', $this->client); $masteries = $api->staticData()->getMasteries('all'); $mastery = $masteries->getMastery(4322); $this->assertEquals('Reduces the cooldown of Summoner Spells by 10%', $mastery->description[2]); }
public function testGetChampionAll() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once(); $this->client->shouldReceive('request')->with('v1.2/champion', ['api_key' => 'key', 'dataById' => 'true', 'champData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/champion.all.json')); $api = new Api('key', $this->client); $champions = $api->staticData()->getChampions('all'); $champion = $champions->getChampion(412); $this->assertEquals('beginner_Starter', $champion->recommended[0]->blocks[0]->type); }
public function testGetItemArray() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/na/')->once(); $this->client->shouldReceive('request')->with('v1.2/item', ['api_key' => 'key', 'itemListData' => 'gold,image'])->once()->andReturn(file_get_contents('tests/Json/Static/items.gold.image.json')); $api = new Api('key', $this->client); $items = $api->staticData()->getItems(array("gold", "image")); $item = $items->getItem(1042); $this->assertEquals(450, $item->gold->total); }
public function testGetSummonerSpellAll() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once(); $this->client->shouldReceive('request')->with('v1.2/summoner-spell', ['api_key' => 'key', 'dataById' => 'true', 'spellData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/summonerspell.all.json')); $api = new Api('key', $this->client); $spells = $api->staticData()->getSummonerSpells('all'); $spell = $spells->getSpell(7); $this->assertEquals('f1', $spell->vars[0]->key); }
public function testGetMasteryAsTreeLegacy() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once(); $this->client->shouldReceive('request')->with('v1.2/mastery', ['api_key' => 'key', 'masteryListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.2015.all.json')); $api = new Api('key', $this->client); $masteries = $api->staticData()->getMasteries('all'); $tree = $masteries->tree; $this->assertInstanceOf('\\LeagueWrap\\Dto\\StaticData\\MasteryTree', $tree); $defenseTree = $tree->Defense; $this->assertTrue(is_array($defenseTree)); $this->assertInstanceOf('\\LeagueWrap\\Dto\\StaticData\\MasteryTreeList', $defenseTree[0]); }
public function updateAction() { // Connect to Riot Api and get champion data $key = ''; $api = new Api($key); $champions = $api->staticData()->getChampions(); // Create transaction $manager = new \Phalcon\Mvc\Model\Transaction\Manager(); $transaction = $manager->get(); // Insert champion id and champion name into MySQL foreach ($champions as $champion) { // Remove spaces, periods, and apostrophes from names to better correspond with img names $to_remove = array("'", ".", " "); $to_replace = array("", "", ""); $champion_name = $champion->name; $champion_name = str_replace($to_remove, $to_replace, $champion_name); // Insert champion id and name $new_champion = new Champion(); $new_champion->setTransaction($transaction); $new_champion->save(array("champion_id" => $champion->id, "champion_name" => $champion_name)); print "Inserted: " . $champion->id . " " . $champion_name . "<br>"; } $transaction->commit(); }
public function testStaticData() { $api = new Api('key'); $staticData = $api->staticData(); $this->assertTrue($staticData instanceof LeagueWrap\Api\Staticdata); }
} else { $platformID = 'garena'; // TODO: other regions that are not provided by RIOT Servers will count as 'garena' too (China / Korea) } include_once 'riot-api-key.php'; // own file with RIOT API key stored to $RIOT_API_KEY variable $api = new Api($RIOT_API_KEY); // Load up the API // TODO: remove jp condition when implemented by RIOT (https://developer.riotgames.com/discussion/announcements/show/9iYdLpZZ) if (strtolower($platformID) !== 'garena' && strtolower($platformID) !== 'jp') { $api->setRegion(mapPlatformIDToRegion($platformID)); } else { $api->setRegion('na'); // TODO: This might lead to differences in data if garena servers are not up to date } $allChamps = $api->staticData()->getChampions(['allytips', 'enemytips', 'image', 'spells', 'passive'])->raw()['data']; /** lower case without spaces */ $allChampsByName = array(); foreach ($allChamps as $champ) { $allChampsByName[normalizeChampName($champ['name'])] = $champ; } $championNames = explode(',', $_REQUEST['championNames']); /** same as we get it from front-end */ $champions = array(); foreach ($championNames as $name) { $champions[$name] = $allChampsByName[normalizeChampName($name)]; } // TODO: reactivate when caching is implemented get own endpoint for this //include_once('championgg.php'); //$champions = gg_addDamageType($champions); //$champions = gg_addStats($champions);
public function testLanguage() { $method = $this->getMethod('LeagueWrap\\Api\\Staticdata', 'setUpParams'); $api = new Api('key', $this->client); $staticData = $api->staticData(); $staticData->setLocale('fr_FR'); $params = $method->invoke($staticData, 'champion', 266, 'tags', 'champData', 'champData'); $expected = ['locale' => 'fr_FR', 'champData' => 'tags']; $this->assertEquals($expected, $params); }