public function testDefaultOptions()
{
// make sure options array loads/saves properly
$optionsArray = array(CURLOPT_PROXY => 'localhost:80');
$withOptionsArray = new CurlClient($optionsArray);
$this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray);
// make sure closure-based options work properly, including argument passing
$ref = null;
$withClosure = new CurlClient(function ($method, $absUrl, $headers, $params, $hasFile) use(&$ref) {
$ref = func_get_args();
return array();
});
$withClosure->request('get', 'https://httpbin.org/status/200', array(), array(), false);
$this->assertSame($ref, array('get', 'https://httpbin.org/status/200', array(), array(), false));
// this is the last test case that will run, since it'll throw an exception at the end
$withBadClosure = new CurlClient(function () {
return 'thisShouldNotWork';
});
$this->setExpectedException('Stripe\\Error\\Api', "Non-array value returned by defaultOptions CurlClient callback");
$withBadClosure->request('get', 'https://httpbin.org/status/200', array(), array(), false);
}