diff --git a/src/Client/Adapter/Curl.php b/src/Client/Adapter/Curl.php index 37620e9cfd..4f516aa8cc 100644 --- a/src/Client/Adapter/Curl.php +++ b/src/Client/Adapter/Curl.php @@ -203,9 +203,9 @@ public function connect($host, $port = 80, $secure = false) } if (isset($this->config['connecttimeout'])) { - $connectTimeout = $this->config['connecttimeout']; + $connectTimeout = (int) $this->config['connecttimeout']; } elseif (isset($this->config['timeout'])) { - $connectTimeout = $this->config['timeout']; + $connectTimeout = (int) $this->config['timeout']; } else { $connectTimeout = null; } diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 89ac19e5f5..bdf5d53495 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -95,6 +95,22 @@ public function testConfigSetAsZendConfig() $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); } + /** + * Test not integer timeout casted to int + * + */ + public function testCastTimeOutConfig() + { + $config = new Config([ + 'timeout' => "timeout", + ]); + + $this->_adapter->setOptions($config); + + $hasConfig = $this->_adapter->getConfig(); + $this->assertEquals((int) $config->timeout, $hasConfig['timeout']); + } + /** * Check that an exception is thrown when trying to set invalid config *