Ensure Curl::setOpts() returns true when all options are successfully set

This commit is contained in:
Zach Borboa
2016-08-29 22:44:48 -07:00
parent 39c21041a5
commit 8db91c79c7
2 changed files with 22 additions and 1 deletions
+1
View File
@@ -947,6 +947,7 @@ class Curl
return false;
}
}
return true;
}
/**
+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()