Test cURL errors in Client

This commit is contained in:
PJ Dietz 2014-07-25 23:35:17 -04:00
parent c9c21fd22e
commit 2d9373e287
1 changed files with 34 additions and 0 deletions

View File

@ -198,4 +198,38 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$server->stop(); $server->stop();
} }
/**
* @dataProvider curlErrorProvider
* @expectedException \pjdietz\WellRESTed\Exceptions\CurlException
*/
public function testFailOnCurlError($uri, $opts)
{
$rqst = $this->getMockBuilder('pjdietz\WellRESTed\Interfaces\RequestInterface')->getMock();
$rqst->expects($this->any())
->method("getUri")
->will($this->returnValue($uri));
$rqst->expects($this->any())
->method("getMethod")
->will($this->returnValue("GET"));
$rqst->expects($this->any())
->method("getPort")
->will($this->returnValue(parse_url($uri, PHP_URL_PORT)));
$rqst->expects($this->any())
->method("getHeaders")
->will($this->returnValue(array()));
$client = new Client();
$client->request($rqst, $opts);
}
public function curlErrorProvider()
{
return [
["http://localhost:9991", [
CURLOPT_FAILONERROR, true,
CURLOPT_TIMEOUT_MS, 10
]],
];
}
} }