/** * Testing the same URL with different data types for the placeholders */ public function testRouteWrongDataType() { // create a request $request = Request::create('/blog/test/42'); // Create a route $r = new Route('blogtest', '/blog/test/{page}', array('controller' => 'example:DemoController:hello'), array('page' => 'int'), array()); // Test that the route matches the request $this->assertTrue($r->isMatch('/blog/test/42', $request)); $r = new Route('another', '/blog/test/{page}', array('controller' => 'example:DemoController:hello'), array('page' => 'alpha'), array()); $this->assertFalse($r->isMatch('/blog/test/42', $request)); }
public function setRedirectToRoute(Route $route, $args = array(), Request $context = null) { // set up the response to redirect to a named route if (!$route) { return; } // generate the url for the route $url = $route->generate($args); // add the domain if we can if ($context) { $url = $context->getHttpHost() . $url; } // Finally, set the redirect headers $this->setRedirectToURL($url); }