From 2d9373e2871ea073cc2cb43db6cc125fb0071b9c Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Fri, 25 Jul 2014 23:35:17 -0400 Subject: [PATCH] Test cURL errors in Client --- test/ClientTest.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/ClientTest.php b/test/ClientTest.php index 330f8a2..830fef1 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -198,4 +198,38 @@ class ClientTest extends \PHPUnit_Framework_TestCase $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 + ]], + ]; + } + }