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')); } }
public function testChampion() { $api = new Api('key'); $champion = $api->champion(); $this->assertTrue($champion instanceof LeagueWrap\Api\Champion); }
/** * @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(); }
/** * @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(); }