Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
cast to (int) for Curl adapter timeout config
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Apr 12, 2017
1 parent 8c23aaa commit 353ec89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions test/Client/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 353ec89

Please sign in to comment.