Exemplo n.º 1
0
 public function testCaching5xxError()
 {
     $response = new LeagueWrap\Response('', 500);
     $exception = new LeagueWrap\Response\Http500('', 500);
     $this->cache->shouldReceive('set')->once()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2', m::any(), 10)->andReturn(true);
     $this->cache->shouldReceive('has')->twice()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2')->andReturn(false, true);
     $this->cache->shouldReceive('get')->once()->with('9bd8e5b11e0ac9c0a52d5711c9057dd2')->andReturn($exception);
     $this->client->shouldReceive('baseUrl')->twice();
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn($response);
     LeagueWrap\StaticApi::mount();
     $api = new LeagueWrap\Api('key', $this->client);
     $api->remember(10, $this->cache);
     $api->setServerErrorCaching();
     $summoner = $api->summoner();
     try {
         $summoner->info('bakasan');
     } catch (LeagueWrap\Response\Http500 $e) {
     }
     try {
         $summoner->info('bakasan');
     } catch (LeagueWrap\Response\Http500 $e) {
     }
     $this->assertEquals(1, $summoner->getRequestCount());
 }