mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 12:14:36 +00:00
Add test for nested arrays in data (#8)
This commit is contained in:
+1
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user