public function testCaching()
 {
     $cachedRequest = new CachedRequest('http://www.google.de');
     $cachedRequest->setCachedResponse(new Response('ich bin gecached http://www.google.de', new HTTP\Header()));
     $oc = new ObjectCache(function ($request) {
         return array($request->getURL());
     }, 200000);
     $oc->store(array('http://www.google.de'), $cachedRequest);
     $this->assertTrue($oc->hit(array('http://www.google.de')));
     $bundle = new RequestBundle(0, $oc);
     $googleReq = $bundle->createRequest('http://www.google.de');
     $this->assertInstanceOf('Psc\\URL\\CachedRequest', $googleReq);
     $this->assertEquals($cachedRequest, $googleReq);
     $this->assertEquals('ich bin gecached http://www.google.de', $googleReq->init()->process());
     $this->assertEquals('ich bin gecached http://www.google.de', $googleReq->getResponse()->getRaw());
 }
Exemple #2
0
 public function addCachedRequest(CachedRequest $cachedRequest)
 {
     $this->requestsCache->store(NULL, $cachedRequest);
     return $this;
 }