Exemplo n.º 1
0
 public function addRouteCollection(RouteCollection $collection)
 {
     $routes = $collection->getRoutes();
     foreach ($routes as $route) {
         $this->routes[] = $route;
     }
 }
Exemplo n.º 2
0
 public function testAddRoute()
 {
     // Create Router, add some Routes
     $router = new Router();
     $routes = [new Route('/foo'), new Route('/bar'), new Route('/baz')];
     foreach ($routes as $route) {
         $router->addRoute($route);
     }
     $this->assertSame($routes, $router->getRoutes());
     // Create a RouteCollection, add some Routes
     $col = new RouteCollection(new Route());
     $col->get('/x', function () {
     });
     $col->get('/y', function () {
     });
     $col->get('/z', function () {
     });
     // Add it to the router
     $router->addRouteCollection($col);
     $allRoutes = array_merge($routes, $col->getRoutes());
     $this->assertSame($allRoutes, $router->getRoutes());
     // Anything added to the collection after adding the collection to the
     // router should not be registered.
     $col->get('/a', function () {
     });
     $col->get('/b', function () {
     });
     $col->get('/c', function () {
     });
     $this->assertSame($allRoutes, $router->getRoutes());
 }
Exemplo n.º 3
0
 /**
  * @expectedException BadMethodCallException
  * @expectedExceptionMessage Method foo does not exist.
  */
 public function testInvalidMethod()
 {
     $baseRoute = new Route();
     $collection = new RouteCollection($baseRoute);
     $collection->foo();
 }