public function testFindRouteByUrl()
 {
     $route = new Route();
     $route->setName('route_repo_test');
     $route->setPath('/path/to/repo');
     $route->setController('GenericBundle:Default:index');
     self::$em->persist($route);
     self::$em->flush();
     self::$em->clear();
     //        $route = new Route;
     //        $root = self::$dm->find(null, self::ROUTE_ROOT);
     //
     //        $route->setPosition($root, 'testroute');
     //        self::$dm->persist($route);
     //
     //        // smuggle a non-route thing into the repository
     //        $noroute = new Generic;
     //        $noroute->setParent($route);
     //        $noroute->setNodename('noroute');
     //        self::$dm->persist($noroute);
     //
     //        $childroute = new Route;
     //        $childroute->setPosition($noroute, 'child');
     //        self::$dm->persist($childroute);
     //
     //        self::$dm->flush();
     //
     //        self::$dm->clear();
     $routes = self::$repository->findRouteByUrl('/path/to/repo');
     $this->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $routes);
     foreach ($routes as $route) {
         $this->assertInstanceOf('Raindrop\\RoutingBundle\\Routing\\Base\\RouteObjectInterface', $route);
     }
     $this->assertCount(1, $routes);
 }
 /**
  * @expectedException Symfony\Component\Routing\Exception\MethodNotAllowedException
  */
 public function testNotAllowed()
 {
     // do not set a content here, or we need a valid request and so on...
     $route = new Route();
     $route->setName('not_allowed');
     $route->setController('testController');
     $route->setRequirement('_method', 'GET');
     $route->setPath('/notallowed');
     self::$em->persist($route);
     self::$em->flush();
     self::$router->getContext()->setMethod('POST');
     self::$router->match('/notallowed');
 }
 public function testSetContent()
 {
     $content = new Route();
     $content->setResolver(self::$resolver);
     $content->setName('my_route_2');
     $content->setPath('/path/to/my/route2');
     $content->setController('AcmeDemoBundle:Default:hello');
     self::$em->persist($content);
     self::$em->flush();
     self::$em->clear();
     $id = $content->getId();
     $route = new Route();
     $route->setResolver(self::$resolver);
     $route->setContent($content);
     $this->assertEquals('Raindrop\\RoutingBundle\\Entity\\Route::' . $id, $route->getRouteContent());
 }
 public function testRedirectDoctrine()
 {
     $route = new Route();
     $route->setResolver(self::$resolver);
     $route->setName('my_route');
     $route->setPath('/path/to/my/route');
     $route->setController('AcmeDemoBundle:Default:index');
     self::$em->persist($route);
     self::$em->flush();
     self::$em->clear();
     $routeRepo = self::$em->getRepository('Raindrop\\RoutingBundle\\Entity\\Route');
     $return = $routeRepo->findOneByPath('/path/to/my/route');
     $this->assertEquals(array('_locale' => null, '_controller' => 'AcmeDemoBundle:Default:index', 'content' => null), $return->getDefaults());
     //        $root = self::$dm->find(null, self::ROUTE_ROOT);
     //
     //        $route = new Route;
     //        $route->setRouteContent($root); // this happens to be a referenceable node
     //        $route->setPosition($root, 'testroute');
     //        self::$dm->persist($route);
     //
     //        $redirect = new RedirectRoute;
     //        $redirect->setPosition($root, 'redirect');
     //        $redirect->setRouteTarget($route);
     //        $redirect->setDefault('test', 'toast');
     //        self::$dm->persist($redirect);
     //
     //        self::$dm->flush();
     //
     //        self::$dm->clear();
     //
     //        $route = self::$dm->find(null, self::ROUTE_ROOT.'/testroute');
     //        $redirect = self::$dm->find(null, self::ROUTE_ROOT.'/redirect');
     //
     //        $this->assertInstanceOf('Symfony\\Cmf\\Component\\Routing\\RedirectRouteInterface', $redirect);
     //        $this->assertSame($redirect, $redirect->getRouteContent());
     //        $params = $redirect->getParameters();
     //        $this->assertArrayHasKey('route', $params);
     //        $this->assertSame($route, $params['route']);
     //        $defaults = $redirect->getDefaults();
     //        $this->assertEquals(array('test' => 'toast'), $defaults);
 }
 public function testExternalPermanentRedirect()
 {
     self::setupBeforeClass();
     $externalRoute = new ExternalRoute();
     $externalRoute->setPermanent();
     $externalRoute->setUri('http://www.twitter.com/');
     self::$em->persist($externalRoute);
     self::$em->flush();
     $route = new Route();
     $route->setResolver(self::$resolver);
     $route->setName('my_redirect_to_external_2');
     $route->setPath('/path/to/external/route2');
     $route->setController('raindrop_routing.generic_controller:redirectRouteAction');
     $route->setContent($externalRoute);
     self::$em->persist($route);
     self::$em->flush();
     $request = new RequestStub();
     $request->param = 'my_route';
     $request->query = new FakeClass();
     $request->query->all = array();
     self::$kernel->getContainer()->set('request', $request);
     $response = self::$controller->redirectRouteAction($externalRoute);
     $this->assertSame(301, $response->getStatusCode());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
     $this->assertSame('http://www.twitter.com/', $response->getTargetUrl());
 }