Example #1
0
 public function testBeforeMatch()
 {
     $this->specify("CLI Router doesn't work with custom before match", function () {
         Route::reset();
         $trace = 0;
         $router = new Router(false);
         $router->add('static route')->beforeMatch(function () use(&$trace) {
             $trace++;
             return false;
         });
         $router->add('static route2')->beforeMatch(function () use(&$trace) {
             $trace++;
             return true;
         });
         $router->handle();
         expect($router->wasMatched())->false();
         $router->handle('static route');
         expect($router->wasMatched())->false();
         $router->handle('static route2');
         expect($router->wasMatched())->true();
         expect($trace)->equals(2);
     });
 }