Fix #13: Remove pass by reference usage; Add "Array to string conversion" test

This commit is contained in:
Zach Borboa
2013-12-28 00:00:57 -08:00
parent a4a0a6de59
commit 92dc6b28a0
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -135,9 +135,9 @@ class Curl {
// Fix "Notice: Array to string conversion" when $value in
// curl_setopt($ch, CURLOPT_POSTFIELDS, $value) is an array
// that contains an empty array.
foreach ($data as &$value) {
foreach ($data as $key => $value) {
if (is_array($value) && empty($value)) {
$value = '';
$data[$key] = '';
}
}
}
+10
View File
@@ -241,4 +241,14 @@ class CurlTest extends PHPUnit_Framework_TestCase {
$test->curl->request_headers);
$this->assertTrue(!empty($content_type));
}
public function testArrayToStringConversion() {
$test = new Test();
$test->server('post', 'POST', array(
'foo' => 'bar',
'baz' => array(
),
));
$this->assertTrue($test->curl->response === 'foo=bar&baz=');
}
}