/** * @test * @group small * @covers ::reset * @covers ::<private> */ public function reset() { $reflectionClass = new \ReflectionClass($this->curlOptionsHandler); $property = $reflectionClass->getProperty('options'); $property->setAccessible(true); $property->setValue($this->curlOptionsHandler, array()); $this->assertInstanceOf(get_class($this->curlOptionsHandler), $this->curlOptionsHandler->reset()); $this->assertSame($this->defaultOptions, $property->getValue($this->curlOptionsHandler)); }
/** * {@inheritdoc} */ public function sendRequest($url, $method, array $options = array(), $payload = '') { if (!$this->assertUrl($url)) { return $this->invalidArgumentException('Invalid url given: ' . $url); } if (!$this->assertString($payload)) { return $this->invalidArgumentException('Invalid payload given: ' . $payload); } if (!$this->assertHttpMethod($method)) { return $this->invalidArgumentException('Invalid http method given: ' . $method); } $this->curlOptionsHandler->setOptions($options); $this->curlOptionsHandler->setOption(CURLOPT_RETURNTRANSFER, true); $this->setUrl($url); $this->setMethod($method); $this->setPayload($payload); curl_setopt_array($this->curl, $this->curlOptionsHandler->getOptions()); $curlResponse = $this->execute(); $curlMetaData = (object) curl_getinfo($this->curl); $this->curlOptionsHandler->reset(); function_exists('curl_reset') ? curl_reset($this->curl) : curl_setopt_array($this->curl, $this->curlOptionsHandler->getOptions()); return $this->createResponse($curlResponse, $curlMetaData); }