/** * @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'); }
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()); }
public function setUp() { $this->client = m::mock('LeagueWrap\\Client'); LeagueWrap\StaticApi::mount(); }
public function setUp() { LeagueWrap\StaticApi::mount(); }
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()); }