mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-06 15:58:10 +00:00
Add curl error test
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user