public function testForCurlRequest()
 {
     $curlRequest = new CurlRequest(curl_init(null));
     $curlRequest->setOption(CURLOPT_RETURNTRANSFER, true);
     $curlRequest->execute();
     $e = new BadHttpResponseException($curlRequest);
     $this->assertContains('error 3', $e->getMessage());
 }
Example #2
0
 public function testExecuteForNullUrl()
 {
     $instance = new CurlRequest(curl_init(null));
     $instance->setOption(CURLOPT_RETURNTRANSFER, true);
     $this->assertTrue($instance->getOption(CURLOPT_RETURNTRANSFER));
     $this->assertFalse($instance->execute());
     $this->assertNull($instance->getOption(CURLOPT_RETURNTRANSFER));
     $this->assertEmpty($instance->getLastTransferInfo(CURLINFO_HTTP_CODE));
 }
Example #3
0
 /**
  * @since  1.0
  *
  * @return mixed
  */
 public function execute()
 {
     list($key, $expiry) = $this->getKeysFromOptions();
     $this->isFromCache = false;
     if ($this->cache->contains($key)) {
         $this->isFromCache = true;
         return $this->cache->fetch($key);
     }
     $response = parent::execute();
     // Do not cache any failed response
     if ($this->getLastErrorCode() !== 0) {
         return $response;
     }
     $this->cache->save($key, $response, $expiry);
     return $response;
 }