コード例 #1
0
 public function testFresh()
 {
     $api1 = Api::setKey('key');
     Api::fresh();
     $api2 = Api::setKey('key');
     $this->assertNotEquals(spl_object_hash($api1), spl_object_hash($api2));
 }
コード例 #2
0
 public function testLeague()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('v2.5/league/by-summoner/272354', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/league.272354.json'));
     Api::setKey('key', $this->client);
     $leagues = League::league(272354);
     $this->assertTrue($leagues[0] instanceof LeagueWrap\Dto\League);
 }
コード例 #3
0
 public function testFree()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'true', 'api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/champion.free.json'));
     Api::setKey('key', $this->client);
     $free = Champion::free();
     $this->assertEquals(10, count($free->champions));
 }
コード例 #4
0
 public function testRanked()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v1.3/stats/by-summoner/74602/ranked', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/stats.ranked.74602.season4.json'));
     Api::setKey('key', $this->client);
     $stats = Stats::ranked(74602);
     $this->assertTrue($stats->champion(0) instanceof LeagueWrap\Dto\ChampionStats);
 }
コード例 #5
0
 public function testStaticItem()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v1.2/item', ['api_key' => 'key', 'locale' => 'ko_KR'])->once()->andReturn(file_get_contents('tests/Json/Static/items.kr.json'));
     Api::setKey('key', $this->client);
     $items = StaticData::setLocale('ko_KR')->getItems();
     $item = $items->getItem(1042);
     $this->assertEquals('단검', $item->name);
 }
コード例 #6
0
 public function testMasteriesSummonerArray()
 {
     $this->client->shouldReceive('baseUrl')->times(2);
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/97235,7024/masteries', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.masteries.7024,97235.json'));
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/7024,97235', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.7024,97235.json'));
     Api::setKey('key', $this->client);
     $summoners = Summoner::info([7024, 97235]);
     Summoner::masteryPages($summoners);
     $this->assertEquals(0, count($summoners['IS1c2d27157a9df3f5aef47']->masteryPages));
 }
コード例 #7
0
 public function testRecentSummoner()
 {
     $this->client->shouldReceive('baseUrl')->twice();
     $this->client->shouldReceive('request')->with('na/v1.3/game/by-summoner/74602/recent', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/game.recent.74602.json'));
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.bakasan.json'));
     Api::setKey('key', $this->client);
     $bakasan = Summoner::info('bakasan');
     $games = Game::recent($bakasan);
     $this->assertTrue($bakasan->recentGame(0) instanceof LeagueWrap\Dto\Game);
 }
コード例 #8
0
ファイル: LimitTest.php プロジェクト: paquettg/leaguewrap
 /**
  * @expectedException LeagueWrap\Exception\LimitReachedException
  */
 public function testSingleLimitStaticProxy()
 {
     $this->limit1->shouldReceive('setRate')->once()->with(1, 10, 'na')->andReturn(true);
     $this->limit1->shouldReceive('hit')->twice()->with(1)->andReturn(true, false);
     $this->limit1->shouldReceive('isValid')->once()->andReturn(true);
     $this->limit1->shouldReceive('getRegion')->twice()->andReturn('na');
     $this->client->shouldReceive('baseUrl')->twice();
     $this->client->shouldReceive('request')->with('v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.bakasan.json'));
     LeagueWrap\StaticApi::mount();
     Api::setKey('key', $this->client);
     Api::limit(1, 10, 'na', $this->limit1);
     Summoner::info('bakasan');
     Summoner::info('bakasan');
 }
コード例 #9
0
ファイル: CacheTest.php プロジェクト: Graves-/leaguewrap
 public function testRememberSummonerStaticProxy()
 {
     $bakasan = file_get_contents('tests/Json/summoner.bakasan.json');
     $this->cache->shouldReceive('set')->once()->with($bakasan, '9bd8e5b11e0ac9c0a52d5711c9057dd2', 10)->andReturn(true);
     $this->cache->shouldReceive('has')->twice()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2')->andReturn(false, true);
     $this->cache->shouldReceive('get')->once()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2')->andReturn($bakasan);
     $this->client->shouldReceive('baseUrl')->twice();
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn($bakasan);
     LeagueWrap\StaticApi::mount();
     Api::setKey('key', $this->client);
     Api::remember(10, $this->cache);
     Summoner::info('bakasan');
     Summoner::info('bakasan');
     $this->assertEquals(1, Summoner::getRequestCount());
 }
コード例 #10
0
 /**
  * @expectedException LeagueWrap\Exception\ListMaxException
  */
 public function testTeamListMaxException()
 {
     Api::setKey('key', $this->client);
     Team::team([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
 }
コード例 #11
0
 public function testNoCaching5xxError()
 {
     $response = new LeagueWrap\Response('', 500);
     $exception = new LeagueWrap\Response\Http500('', 500);
     $this->cache->shouldReceive('has')->twice()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2')->andReturn(false, false);
     $this->client->shouldReceive('baseUrl')->twice();
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->twice()->andReturn($response);
     LeagueWrap\StaticApi::mount();
     Api::setKey('key', $this->client);
     Api::remember(10, $this->cache);
     try {
         Summoner::info('bakasan');
     } catch (LeagueWrap\Response\Http500 $e) {
     }
     try {
         Summoner::info('bakasan');
     } catch (LeagueWrap\Response\Http500 $e) {
     }
     $this->assertEquals(2, Summoner::getRequestCount());
 }