Fix missing nested POST data values and add tests

This commit is contained in:
Zach Borboa
2013-12-28 08:03:51 -08:00
parent 92dc6b28a0
commit 1bd59855d6
2 changed files with 29 additions and 0 deletions
+4
View File
@@ -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) {
+25
View File
@@ -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'
);
}
}