Add curl error test

This commit is contained in:
php-curl-class
2013-08-19 12:34:37 -07:00
parent a486962f8d
commit 09a6c3b667
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -72,6 +72,7 @@ class Curl {
$this->response = curl_exec($this->curl);
$this->error_code = curl_errno($this->curl);
$this->error_message = curl_error($this->curl);
$this->error = !($this->error_code === 0);
return $this->error_code;
}
+8
View File
@@ -68,4 +68,12 @@ class CurlTest extends PHPUnit_Framework_TestCase {
$test->curl->setCookie('mycookie', 'yum');
$this->assertTrue($test->server('GET', 'cookie', 'mycookie') === 'yum');
}
public function testError() {
$test = new Test();
$test->curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 2000);
$test->curl->get('http://1.2.3.4/');
$this->assertTrue($test->curl->error === TRUE);
$this->assertTrue($test->curl->error_code === CURLE_OPERATION_TIMEOUTED);
}
}