/** * Verify basic functionality of clear(). * * @test * @covers ::clear * * @return void */ public function clear() { $cache = new ArrayCache(); $request = new Request('not under test', 'not under test', [], []); $cache->set($request, new Response(200, [], [])); $this->assertNotNull($cache->get($request)); $cache->clear(); $this->assertNull($cache->get($request)); }
/** * Verfiy response is return from cache. * * @test * @covers ::get * * @return void */ public function getSetsCache() { \Chadicus\FunctionRegistry::set(__NAMESPACE__, 'time', function () { return 1; }); $hash = md5('1aPrivateKeyaPublicKey'); $request = new Request(Client::BASE_URL . "a+Resource/1?apikey=aPublicKey&ts=1&hash={$hash}", 'GET'); $cache = new Cache\ArrayCache(); $adapter = new FakeAdapter(); $client = new Client('aPrivateKey', 'aPublicKey', $adapter, $cache); $response = $client->get('a Resource', 1); $cachedResponse = $cache->get($request); $this->assertSame($response->getHttpCode(), $cachedResponse->getHttpCode()); $this->assertSame($response->getHeaders(), $cachedResponse->getHeaders()); $this->assertSame($response->getBody(), $cachedResponse->getBody()); }