Exemplo n.º 1
0
 public function testAddPrefix()
 {
     $collection = new RouteCollection();
     $collection->addRoute('foo', $foo = new Route('/foo'));
     $collection->addRoute('bar', $bar = new Route('/bar'));
     $collection->addPrefix('/admin');
     $this->assertEquals('/admin/foo', $collection->getRoute('foo')->getPattern(), '->addPrefix() adds a prefix to all routes');
     $this->assertEquals('/admin/bar', $collection->getRoute('bar')->getPattern(), '->addPrefix() adds a prefix to all routes');
 }
Exemplo n.º 2
0
 /**
  * @covers Symfony\Component\Routing\Loader\ClosureLoader::load
  */
 public function testLoad()
 {
     $loader = new ClosureLoader();
     $route = new Route('/');
     $routes = $loader->load(function () use($route) {
         $routes = new RouteCollection();
         $routes->addRoute('foo', $route);
         return $routes;
     });
     $this->assertEquals($route, $routes->getRoute('foo'), '->load() loads a \\Closure resource');
 }
Exemplo n.º 3
0
 /**
  * @covers Symfony\Component\Routing\Loader\DelegatingLoader::load
  */
 public function testLoad()
 {
     $resolver = new LoaderResolver(array(new ClosureLoader()));
     $loader = new DelegatingLoader($resolver);
     $route = new Route('/');
     $routes = $loader->load(function () use($route) {
         $routes = new RouteCollection();
         $routes->addRoute('foo', $route);
         return $routes;
     });
     $this->assertSame($route, $routes->getRoute('foo'), '->load() loads a resource using the loaders from the resolver');
     try {
         $loader->load('foo.foo');
         $this->fail('->load() throws an \\InvalidArgumentException if the resource cannot be loaded');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an \\InvalidArgumentException if the resource cannot be loaded');
     }
 }