1
0
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:
Michael Dowling 2012-07-23 22:50:38 -07:00
parent c76e287134
commit bc6cbc8cd3
2 changed files with 15 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}
}