Add test for nested arrays in data (#8)

This commit is contained in:
Zach Borboa
2013-12-19 08:03:26 -08:00
parent 5acdd246be
commit 584ecf904d
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ class Curl {
$query[] = urlencode(is_null($key) ? $k : $key . $brackets) . '=' . rawurlencode($value);
}
else if (is_array($value)) {
$nested = (is_null($key)) ? $k : $key . '[' . $k . ']';
$nested = is_null($key) ? $k : $key . '[' . $k . ']';
$query[] = $this->http_build_multi_query($value, $nested);
}
}
+19
View File
@@ -201,4 +201,23 @@ class CurlTest extends PHPUnit_Framework_TestCase {
$test = new Test();
$this->assertFalse(substr($test->server('request_uri', 'DELETE'), -1) === '?');
}
public function testNestedData() {
$test = new Test();
$data = array(
'username' => 'myusername',
'password' => 'mypassword',
'more_data' => array(
'param1' => 'something',
'param2' => 'other thing',
'another' => array(
'extra' => 'level',
'because' => 'I need it',
),
),
);
$this->assertTrue(
$test->server('post', 'POST', $data) === http_build_query($data)
);
}
}