public function test_RESTfulApp_route_chaining() { $request = $this->_buildRequest('GET', '/api/user/lcrouch'); $this->_front->setRequest($request); $router = $this->_front->getRouter(); $router->removeDefaultRoutes(); $nonRESTRoute = new Route('api'); $RESTRoute = new Rest\Route($this->_front); $router->addRoute("api", $nonRESTRoute->addChain($RESTRoute)); $routedRequest = $router->route($request); $this->assertEquals("default", $routedRequest->getParam("module")); $this->assertEquals("user", $routedRequest->getParam("controller")); $this->assertEquals("get", $routedRequest->getParam("action")); $this->assertEquals("lcrouch", $routedRequest->getParam("id")); }
public function testI18nChaining() { $lang = new Route\Route(':lang', array('lang' => 'en')); $profile = new Route\Route('user/:id', array('controller' => 'foo', 'action' => 'bar')); $chain = $lang->addChain($profile); $res = $chain->match(new Request('http://localhost/en/user/1')); $this->assertEquals('en', $res['lang']); $this->assertEquals('1', $res['id']); }
public function testEscapedSpecialCharsWithTranslation() { $route = new Route\Route('::foo/@@bar/:@myvar'); $path = $route->assemble(array('myvar' => 'foo')); $this->assertEquals($path, ':foo/@bar/en_foo'); $values = $route->match(':foo/@bar/en_foo'); $this->assertEquals($values['myvar'], 'foo'); }