diff --git a/src/Client.php b/src/Client.php index 71606b3949..34fac60c84 100644 --- a/src/Client.php +++ b/src/Client.php @@ -832,7 +832,7 @@ public function send(Request $request = null) if (!empty($queryArray)) { $newUri = $uri->toString(); - $queryString = http_build_query($query, null, $this->getArgSeparator()); + $queryString = http_build_query($queryArray, null, $this->getArgSeparator()); if ($this->config['rfc3986strict']) { $queryString = str_replace('+', '%20', $queryString); diff --git a/test/ClientTest.php b/test/ClientTest.php index da22793267..3ef89364e2 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -395,4 +395,36 @@ public function testCanSpecifyCustomAuthMethodsInExtendingClasses() $client ); } + + /** + * @group 6231 + */ + public function testHttpQueryParametersCastToString() + { + $client = new Client(); + + /* @var $adapter \PHPUnit_Framework_MockObject_MockObject|\Zend\Http\Client\Adapter\AdapterInterface */ + $adapter = $this->getMock('Zend\Http\Client\Adapter\AdapterInterface'); + + $client->setAdapter($adapter); + + $request = new Request(); + + $request->setUri('http://example.com/'); + $request->getQuery()->set('foo', 'bar'); + + $response = new Response(); + + $adapter + ->expects($this->once()) + ->method('write') + ->with(Request::METHOD_GET, 'http://example.com/?foo=bar'); + + $adapter + ->expects($this->any()) + ->method('read') + ->will($this->returnValue($response->toString())); + + $client->send($request); + } }