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()); }
public function testRouterGeneratesRouteParameters() { /** @var $controller WsServerInterface */ $controller = $this->getMockBuilder('\\Ratchet\\WebSocket\\WsServer')->disableOriginalConstructor()->getMock(); /** @var $matcher UrlMatcherInterface */ $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', 'ws://random.url'), '', false); $request->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); $request->setHeaderFactory($this->getMock('Guzzle\\Http\\Message\\Header\\HeaderFactoryInterface')); $request->setUrl('ws://doesnt.matter/'); $router = new Router($this->_matcher); $router->onOpen($conn, $request); $this->assertEquals(array('foo' => 'bar', 'baz' => 'qux'), $request->getQuery()->getAll()); }