Merge pull request #383 from zachborboa/master

Ensure Curl::setOpts() returns true when all options are successfully set
This commit is contained in:
Zach Borboa
2016-08-30 00:08:13 -07:00
committed by GitHub
4 changed files with 34 additions and 8 deletions
+1 -3
View File
@@ -35,7 +35,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
*
* @param mixed[] $initial (optional) Existing Array to convert.
*
* @return void
* @return CaseInsensitiveArray
*
* @access public
*/
@@ -205,8 +205,6 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
*
* @see https://secure.php.net/manual/en/iterator.valid.php
*
* @param void
*
* @return bool If the current position is valid.
*
* @access public
+10 -2
View File
@@ -403,6 +403,8 @@ class Curl
*
* @access public
* @param $opt
*
* @return mixed
*/
public function getInfo($opt)
{
@@ -514,8 +516,8 @@ class Curl
* @access public
* @param $url
* @param $data
* @param $follow_303_with_post If true, will cause 303 redirections to be followed using
* a POST request (default: false).
* @param $follow_303_with_post
* If true, will cause 303 redirections to be followed using a POST request (default: false).
* Notes:
* - Redirections are only followed if the CURLOPT_FOLLOWLOCATION option is set to true.
* - According to the HTTP specs (see [1]), a 303 redirection should be followed using
@@ -688,6 +690,7 @@ class Curl
*
* @access public
* @param $key
*
* @return mixed
*/
public function getCookie($key)
@@ -700,6 +703,7 @@ class Curl
*
* @access public
* @param $key
*
* @return mixed
*/
public function getResponseCookie($key)
@@ -711,6 +715,7 @@ class Curl
* Get response cookies.
*
* @access public
*
* @return array
*/
public function getResponseCookies()
@@ -745,6 +750,8 @@ class Curl
*
* @access public
* @param $string
*
* @return bool
*/
public function setCookieString($string)
{
@@ -947,6 +954,7 @@ class Curl
return false;
}
}
return true;
}
/**
+2 -2
View File
@@ -193,8 +193,8 @@ class MultiCurl
* @access public
* @param $url
* @param $data
* @param $follow_303_with_post If true, will cause 303 redirections to be followed using
* GET requests (default: false).
* @param $follow_303_with_post
* If true, will cause 303 redirections to be followed using GET requests (default: false).
* Note: Redirections are only followed if the CURLOPT_FOLLOWLOCATION option is set to true.
*
* @return object
+21 -1
View File
@@ -2837,14 +2837,34 @@ class CurlTest extends PHPUnit_Framework_TestCase
CURLOPT_COOKIE => 'a=b',
);
$curl = new Curl();
@$curl->setOpts($options);
$success = @$curl->setOpts($options);
$reflector = new ReflectionObject($curl);
$property = $reflector->getProperty('options');
$property->setAccessible(true);
$options = $property->getValue($curl);
$this->assertFalse($success);
$this->assertFalse(isset($options[CURLOPT_COOKIE]));
// Ensure Curl::setOpts() returns true when all options are successfully set.
$options = array(
CURLOPT_COOKIE => 'a=b',
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_VERBOSE => true,
);
$curl = new Curl();
$success = $curl->setOpts($options);
$reflector = new ReflectionObject($curl);
$property = $reflector->getProperty('options');
$property->setAccessible(true);
$options = $property->getValue($curl);
$this->assertTrue($success);
$this->assertEquals('a=b', $options[CURLOPT_COOKIE]);
$this->assertTrue($options[CURLOPT_FOLLOWLOCATION]);
$this->assertTrue($options[CURLOPT_VERBOSE]);
}
public function testBuildUrlArgSeparator()