From 3edd0cdd7e571f67b6d6cf017d71ea6f05ca7230 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 14 Sep 2014 11:19:37 -0400 Subject: [PATCH] Added unit test for query parameter fix closes #220 closes #228 closes #229 --- tests/unit/Http/RouterTest.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 3615be0..5a1128e 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -98,8 +98,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase { $this->_router->onError($this->_conn, $e); } - public function testRouterGeneratesRouteParameters() - { + public function testRouterGeneratesRouteParameters() { /** @var $controller WsServerInterface */ $controller = $this->getMockBuilder('\Ratchet\WebSocket\WsServer')->disableOriginalConstructor()->getMock(); /** @var $matcher UrlMatcherInterface */ @@ -120,4 +119,22 @@ class RouterTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(array('foo' => 'bar', 'baz' => 'qux'), $request->getQuery()->getAll()); } + + public function testQueryParams() { + $controller = $this->getMockBuilder('\Ratchet\WebSocket\WsServer')->disableOriginalConstructor()->getMock(); + $this->_matcher->expects($this->any())->method('match')->will( + $this->returnValue(array('_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux')) + ); + + $conn = $this->getMock('Ratchet\Mock\Connection'); + $request = $this->getMock('Guzzle\Http\Message\Request', array('getPath'), array('GET', ''), '', false); + + $request->setHeaderFactory($this->getMock('Guzzle\Http\Message\Header\HeaderFactoryInterface')); + $request->setUrl('ws://doesnt.matter?hello=world&foo=nope'); + + $router = new Router($this->_matcher); + $router->onOpen($conn, $request); + + $this->assertEquals(array('foo' => 'nope', 'baz' => 'qux', 'hello' => 'world'), $request->getQuery()->getAll()); + } }