public function testDeprecatedFunctions() { $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMockForAbstractClass(); $instance = new CachedCurlRequest(curl_init(), $cache); $instance->setExpiryInSeconds(42); $instance->setCachePrefix('Foo'); $this->assertEquals(42, $instance->getOption(ONOI_HTTP_REQUEST_RESPONSECACHE_TTL)); $this->assertEquals('Foo', $instance->getOption(ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX)); }
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()); }