public function testCachedRequestToExternalUrl()
 {
     $target = 'http://example.org/';
     $cache = new FixedInMemoryLruCache();
     $instance = new CachedCurlRequest(curl_init($target), $cache);
     if (!$instance->ping()) {
         $this->markTestSkipped("Can't connect to " . $target);
     }
     $instance->setExpiryInSeconds(42);
     $instance->setOption(CURLOPT_RETURNTRANSFER, true);
     $this->assertInternalType('string', $instance->execute());
     $this->assertFalse($instance->isCached());
     // Repeated request
     $instance->setOption(CURLOPT_RETURNTRANSFER, true);
     $instance->execute();
     $this->assertTrue($instance->isCached());
 }
 public function testExecuteForRepeatedRequest()
 {
     $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->setMethods(array('contains', 'fetch'))->getMockForAbstractClass();
     $cache->expects($this->once())->method('contains')->with($this->equalTo('foo:onoi:http:5e5c38ee7b39e4af8dcf83c14392201b'))->will($this->returnValue(true));
     $cache->expects($this->once())->method('fetch')->will($this->returnValue(22));
     $instance = new CachedCurlRequest(curl_init(), $cache);
     $instance->setCachePrefix('foo:');
     $instance->setOption(CURLOPT_RETURNTRANSFER, true);
     $this->assertEquals(22, $instance->execute());
     $this->assertTrue($instance->isCached());
 }