public function testSslOption() { // make sure options array loads/saves properly $optionsArray = array(CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1); $withOptionsArray = new CurlClient($optionsArray); $this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); }
public function testEncode() { $a = array('my' => 'value', 'that' => array('your' => 'example'), 'bar' => 1, 'baz' => null); $enc = CurlClient::encode($a); $this->assertSame('my=value&that%5Byour%5D=example&bar=1', $enc); $a = array('that' => array('your' => 'example', 'foo' => null)); $enc = CurlClient::encode($a); $this->assertSame('that%5Byour%5D=example', $enc); $a = array('that' => 'example', 'foo' => array('bar', 'baz')); $enc = CurlClient::encode($a); $this->assertSame('that=example&foo%5B%5D=bar&foo%5B%5D=baz', $enc); $a = array('my' => 'value', 'that' => array('your' => array('cheese', 'whiz', null)), 'bar' => 1, 'baz' => null); $enc = CurlClient::encode($a); $expected = 'my=value&that%5Byour%5D%5B%5D=cheese' . '&that%5Byour%5D%5B%5D=whiz&bar=1'; $this->assertSame($expected, $enc); // Ignores an empty array $enc = CurlClient::encode(array('foo' => array(), 'bar' => 'baz')); $expected = 'bar=baz'; $this->assertSame($expected, $enc); }
/** * @return HttpClient\CurlClient */ private function httpClient() { if (!self::$_httpClient) { self::$_httpClient = HttpClient\CurlClient::instance(); } return self::$_httpClient; }