Example #1
0
 public function testMiddleware()
 {
     $router = new RouteCollection();
     $router->group(function (RouteCollection $router) {
         $router->group(function (RouteCollection $router) {
             $router->route('GET', '/path', 'handler')->middleware(['m1', 'm2']);
         })->middleware(['m3', 'm4']);
     })->middleware(['m5', 'm6']);
     $routes = $router->getRoutes();
     $this->assertRoute('GET', '/path', 'handler', ['m1', 'm2', 'm3', 'm4', 'm5', 'm6'], reset($routes));
     $this->assertFalse(next($routes));
     $router = new RouteCollection();
     $router->group(function (RouteCollection $router) {
         $router->group(function (RouteCollection $router) {
             $router->route('GET', '/path', 'handler')->middleware('m1')->middleware('m2');
         })->middleware('m3')->middleware('m4');
     })->middleware('m5')->middleware('m6');
     $routes = $router->getRoutes();
     $this->assertRoute('GET', '/path', 'handler', ['m1', 'm2', 'm3', 'm4', 'm5', 'm6'], reset($routes));
     $this->assertFalse(next($routes));
 }
Example #2
0
 /**
  * @param callable $callback
  * @return \Fastra\RouteCollection
  */
 public function group(callable $callback)
 {
     return $this->routeCollection->group($callback);
 }