예제 #1
0
 public function testUnderlyingServiceExceptionContainsResponse()
 {
     try {
         $this->simulateWithResponse(new Response('', 429, []));
         $api = new Api('key', $this->client);
         $api->champion()->all();
     } catch (ResponseException $e) {
         $this->assertTrue($e->hasResponse());
         $this->assertInstanceOf(UnderlyingServiceRateLimitReached::class, $e);
         $this->assertInstanceOf(Response::class, $e->getResponse());
         $this->assertFalse($e->getResponse()->hasHeader('Retry-After'));
         $this->assertFalse($e->getResponse()->hasHeader('X-Rate-Limit-Type'));
         $this->assertCount(0, $e->getResponse()->getHeaders());
         $this->assertEquals([], $e->getResponse()->getHeaders());
         $this->assertNull($e->getResponse()->getHeader('Retry-After'));
         $this->assertNull($e->getResponse()->getHeader('X-Rate-Limit-Type'));
     }
 }
예제 #2
0
 public function testChampion()
 {
     $api = new Api('key');
     $champion = $api->champion();
     $this->assertTrue($champion instanceof LeagueWrap\Api\Champion);
 }
예제 #3
0
 /**
  * @expectedException LeagueWrap\Response\Http429
  * @expectedExceptionMessage Rate limit exceeded.
  */
 public function testNormalRateLimitReached()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'false', 'api_key' => 'key'])->once()->andReturn(new LeagueWrap\Response('', 429, ['Retry-After' => 123, 'X-Rate-Limit-Type' => 'user']));
     $api = new Api('key', $this->client);
     $champion = $api->champion();
     $champions = $champion->all();
 }
예제 #4
0
 /**
  * @expectedException LeagueWrap\Response\Http400
  * @expectedExceptionMessage Bad request.
  */
 public function testAllBadRquest()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'false', 'api_key' => 'key'])->once()->andReturn(new LeagueWrap\Response('', 400));
     $api = new Api('key', $this->client);
     $champion = $api->champion();
     $champions = $champion->all();
 }