public function testGetRealmKR() { $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.kr.json')); $api = new Api('key', $this->client); $kr = $api->setRegion('kr')->staticData()->getRealm(); $this->assertEquals('ko_KR', $kr->l); }
public function testGetShardStatus() { $this->client->shouldReceive('baseUrl')->with('http://status.leagueoflegends.com/')->once(); $this->client->shouldReceive('request')->with('shards/euw', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/shardstatus.euw.json')); $api = new Api('key', $this->client); $api->setRegion('euw'); $shardStatus = $api->status()->shardStatus(); $this->assertTrue($shardStatus instanceof \LeagueWrap\Dto\ShardStatus); }
public function testGetRuneRegionKR() { $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/kr/')->once(); $this->client->shouldReceive('request')->with('v1.2/rune', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/rune.kr.json')); $api = new Api('key', $this->client); $runes = $api->setRegion('kr')->staticData()->getRunes(); $rune = $runes->getRune(5267); $this->assertEquals('상급 주문력 표식', $rune->name); }
public function testScore() { $this->client->shouldReceive('baseUrl')->with('https://euw.api.pvp.net/championmastery/location/EUW1/')->once(); $this->client->shouldReceive('request')->with('player/30447079/score', ['api_key' => 'key'])->once()->andReturn(100); $api = new Api('key', $this->client); $api->setRegion('euw'); $score = $api->championMastery()->score(30447079); $this->assertTrue($score == 100); }
public function testGetSummonerSpellRegionTR() { $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'])->once()->andReturn(file_get_contents('tests/Json/Static/summonerspell.tr.json')); $api = new Api('key', $this->client); $spells = $api->setRegion('tr')->staticData()->getSummonerSpells(); $spell = $spells->getSpell(6); $this->assertEquals('Hayalet', $spell->name); }
public function testCurrentGameParticipantRunes() { $this->client->shouldReceive('baseUrl')->once(); $this->client->shouldReceive('request')->with('consumer/getSpectatorGameInfo/EUW1/30447079', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/currentgame.30447079.json')); $api = new Api('key', $this->client); $api->setRegion('euw'); $game = $api->currentGame()->currentGame(30447079); $participant = $game->participant(28882300); $this->assertTrue($participant->rune(5253) instanceof \LeagueWrap\Dto\Rune); $this->assertTrue($participant->rune(5253)->count == 9); }
public function testAttachStaticData() { $this->client->shouldReceive('baseUrl')->with('https://euw.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo/EUW1/')->once(); $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->times(4); $this->client->shouldReceive('request')->with('30447079', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/currentgame.30447079.json')); $this->client->shouldReceive('request')->with('v1.2/champion', ['api_key' => 'key', 'dataById' => 'true'])->once()->andReturn(file_get_contents('tests/Json/Static/champion.euw.json')); $this->client->shouldReceive('request')->with('v1.2/summoner-spell', ['api_key' => 'key', 'dataById' => 'true'])->once()->andReturn(file_get_contents('tests/Json/Static/summonerspell.euw.json')); $this->client->shouldReceive('request')->with('v1.2/mastery', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.euw.json')); $this->client->shouldReceive('request')->with('v1.2/rune', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/rune.euw.json')); $api = new Api('key', $this->client); $api->setRegion('euw'); $api->attachStaticData(true); $game = $api->currentGame()->currentGame(30447079); $participant = $game->participant(28882300); $rune = $participant->rune(5253); $this->assertTrue($rune->runeStaticData instanceof LeagueWrap\Dto\StaticData\Rune); $masteries = $participant->masteries; $this->assertTrue($masteries[6111]->masteryStaticData instanceof LeagueWrap\Dto\StaticData\Mastery); }
include_once './dataFiltering.php'; use LeagueWrap\Api; $platformID = ""; if (isset($_REQUEST['server'])) { $platformID = $_REQUEST['server']; } 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)];
public function testAllRegionRU() { $this->client->shouldReceive('baseUrl')->once()->with('https://ru.api.pvp.net/api/lol/ru/'); $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'false', 'api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/champion.ru.json')); $api = new Api('key', $this->client); $api->setRegion('ru'); $champion = $api->champion(); $champions = $champion->all(); $this->assertTrue($champions->getChampion(53) instanceof LeagueWrap\Dto\Champion); }
<?php require 'vendor/autoload.php'; use LeagueWrap\Api; $api = new Api('67ec97d4-97e6-4db2-8102-92ac79eae66e'); $api->setRegion('euw'); $summoner = $api->summoner(); $info = $summoner->info('stahp fgt'); echo '<pre>', print_r($info, true);