mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-28 11:09:26 +00:00
Fix missing nested POST data values and add tests
This commit is contained in:
@@ -106,6 +106,10 @@ class Curl {
|
||||
private function http_build_multi_query($data, $key=NULL) {
|
||||
$query = array();
|
||||
|
||||
if (empty($data)) {
|
||||
return $key . '=';
|
||||
}
|
||||
|
||||
$is_array_assoc = is_array_assoc($data);
|
||||
|
||||
foreach ($data as $k => $value) {
|
||||
|
||||
@@ -250,5 +250,30 @@ class CurlTest extends PHPUnit_Framework_TestCase {
|
||||
),
|
||||
));
|
||||
$this->assertTrue($test->curl->response === 'foo=bar&baz=');
|
||||
|
||||
$test = new Test();
|
||||
$test->server('post', 'POST', array(
|
||||
'foo' => 'bar',
|
||||
'baz' => array(
|
||||
'qux' => array(
|
||||
),
|
||||
),
|
||||
));
|
||||
$this->assertTrue(urldecode($test->curl->response) ===
|
||||
'foo=bar&baz[qux]='
|
||||
);
|
||||
|
||||
$test = new Test();
|
||||
$test->server('post', 'POST', array(
|
||||
'foo' => 'bar',
|
||||
'baz' => array(
|
||||
'qux' => array(
|
||||
),
|
||||
'wibble' => 'wobble',
|
||||
),
|
||||
));
|
||||
$this->assertTrue(urldecode($test->curl->response) ===
|
||||
'foo=bar&baz[qux]=&baz[wibble]=wobble'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user