commit
3ab853aa80
@ -53,6 +53,8 @@ class Router implements HttpServerInterface {
|
|||||||
$parameters[$key] = $value;
|
$parameters[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$parameters = array_merge($parameters, $request->getQuery()->getAll());
|
||||||
|
|
||||||
$url = Url::factory($request->getPath());
|
$url = Url::factory($request->getPath());
|
||||||
$url->setQuery($parameters);
|
$url->setQuery($parameters);
|
||||||
$request->setUrl($url);
|
$request->setUrl($url);
|
||||||
|
@ -15,8 +15,18 @@ class RouterTest extends \PHPUnit_Framework_TestCase {
|
|||||||
protected $_req;
|
protected $_req;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
$queryMock = $this->getMock('Guzzle\Http\QueryString');
|
||||||
|
$queryMock
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getAll')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
$this->_conn = $this->getMock('\Ratchet\ConnectionInterface');
|
$this->_conn = $this->getMock('\Ratchet\ConnectionInterface');
|
||||||
$this->_req = $this->getMock('\Guzzle\Http\Message\RequestInterface');
|
$this->_req = $this->getMock('\Guzzle\Http\Message\RequestInterface');
|
||||||
|
$this->_req
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getQuery')
|
||||||
|
->will($this->returnValue($queryMock));
|
||||||
$this->_matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
|
$this->_matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
|
||||||
$this->_matcher
|
$this->_matcher
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -88,8 +98,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$this->_router->onError($this->_conn, $e);
|
$this->_router->onError($this->_conn, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRouterGeneratesRouteParameters()
|
public function testRouterGeneratesRouteParameters() {
|
||||||
{
|
|
||||||
/** @var $controller WsServerInterface */
|
/** @var $controller WsServerInterface */
|
||||||
$controller = $this->getMockBuilder('\Ratchet\WebSocket\WsServer')->disableOriginalConstructor()->getMock();
|
$controller = $this->getMockBuilder('\Ratchet\WebSocket\WsServer')->disableOriginalConstructor()->getMock();
|
||||||
/** @var $matcher UrlMatcherInterface */
|
/** @var $matcher UrlMatcherInterface */
|
||||||
@ -110,4 +119,22 @@ class RouterTest extends \PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
$this->assertEquals(array('foo' => 'bar', 'baz' => 'qux'), $request->getQuery()->getAll());
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user