Example #1
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());
 }