/** * @test */ public function shouldRenewCacheWhenResourceHasChanged() { $client = $this->getMock('Buzz\\Client\\ClientInterface', array('setTimeout', 'setVerifyPeer', 'send')); $client->expects($this->once())->method('send'); $cache = $this->getCacheMock(); $response = new Response(); $response->addHeader('HTTP/1.1 200 OK'); $httpClient = new TestCachedHttpClient(array('base_url' => ''), $client); $httpClient->setCache($cache); $httpClient->fakeResponse = $response; $cache->expects($this->once())->method('set')->with('test', $response); $cache->expects($this->once())->method('getModifiedSince')->with('test')->will($this->returnValue(1256953732)); $httpClient->get('test'); }
/** * @test * @expectedException \Github\Exception\ApiLimitExceedException */ public function shouldThrowExceptionWhenApiIsExceeded() { $path = '/some/path'; $parameters = array('a' => 'b'); $headers = array('c' => 'd'); $response = new Response(); $response->addHeader('HTTP/1.1 403 Forbidden'); $response->addHeader('X-RateLimit-Remaining: 0'); $httpClient = new TestHttpClient(array(), $this->getBrowserMock()); $httpClient->setFakeResponse($response); $httpClient->get($path, $parameters, $headers); }