Exemplo n.º 1
0
 public function testRedirectDoctrine()
 {
     $content = $this->createContent();
     $root = $this->getDm()->find(null, self::ROUTE_ROOT);
     $route = new Route();
     $route->setContent($content);
     $route->setPosition($root, 'testroute');
     $this->getDm()->persist($route);
     $redirect = new RedirectRoute();
     $redirect->setPosition($root, 'redirect');
     $redirect->setRouteTarget($route);
     $redirect->setDefault('test', 'toast');
     $this->getDm()->persist($redirect);
     $this->getDm()->flush();
     $this->getDm()->clear();
     $route = $this->getDm()->find(null, self::ROUTE_ROOT . '/testroute');
     $redirect = $this->getDm()->find(null, self::ROUTE_ROOT . '/redirect');
     $this->assertInstanceOf('Symfony\\Cmf\\Component\\Routing\\RedirectRouteInterface', $redirect);
     $this->assertSame($redirect, $redirect->getContent());
     $params = $redirect->getParameters();
     $this->assertSame($route, $redirect->getRouteTarget());
     $defaults = $redirect->getDefaults();
     $this->assertEquals(array('test' => 'toast'), $defaults);
 }
Exemplo n.º 2
0
 public function testEnhanceControllerByAlias()
 {
     // put a redirect route
     $root = $this->getDm()->find(null, self::ROUTE_ROOT);
     $route = new RedirectRoute();
     $route->setDefault('type', 'demo_alias');
     $route->setPosition($root, 'controlleralias');
     $this->getDm()->persist($route);
     $this->getDm()->flush();
     $expected = array('_controller' => 'test.controller:aliasAction', RouteObjectInterface::ROUTE_NAME => '/test/routing/controlleralias', 'type' => 'demo_alias');
     $request = Request::create('/controlleralias');
     $matches = $this->router->matchRequest($request);
     ksort($matches);
     $this->assertTrue($request->attributes->has(DynamicRouter::ROUTE_KEY));
     $this->assertEquals($expected, $matches);
 }