mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 02:22:57 +01:00
[Http] Fixing bug where query string values of 0 were not being set. Closes #108.
This commit is contained in:
parent
c76e287134
commit
bc6cbc8cd3
@ -89,7 +89,7 @@ class QueryString extends Collection
|
||||
$firstValue = true;
|
||||
|
||||
foreach ($this->encodeData($this->data) as $name => $value) {
|
||||
$value = $value ? (array) $value : array('');
|
||||
$value = $value === null ? array('') : (array) $value;
|
||||
foreach ($value as $v) {
|
||||
if ($firstValue) {
|
||||
$firstValue = false;
|
||||
|
@ -255,4 +255,18 @@ class QueryStringTest extends \Guzzle\Tests\GuzzleTestCase
|
||||
$query = QueryString::fromString('var=foo+bar');
|
||||
$this->assertEquals('foo bar', $query->get('var'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Guzzle\Http\QueryString::__toString
|
||||
*/
|
||||
public function testAllowsZeroValues()
|
||||
{
|
||||
$query = new QueryString(array(
|
||||
'foo' => 0,
|
||||
'baz' => '0',
|
||||
'bar' => null,
|
||||
'boo' => false
|
||||
));
|
||||
$this->assertEquals('?foo=0&baz=0&bar=&boo=', (string) $query);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user