Example #1
0
 public function test_group()
 {
     $router = new Router();
     $anotherRouter = $router->group();
     $this->assertTrue($anotherRouter instanceof IRouter);
     $this->assertTrue($router !== $anotherRouter);
 }
 function it_runs(IInput $input, IOutput $output)
 {
     $router = new Router();
     $router->addFilter('filter', function () {
     });
     for ($i = 0; $i < 15; $i++) {
         $router->get('/some/path', 'value');
     }
     for ($i = 0; $i < 15; $i++) {
         $router->group()->get('/another/path', 'value');
     }
     $router->enableFilter('filter');
     $this->run($input, $output, $router);
 }
Example #3
0
 public function test_that_exceptions_thrown_by_filters_do_not_get_swallowed()
 {
     $router = new Router();
     $router->addFilter('foo', function () {
         throw new Exception('foo bar');
     });
     $router->group(function (IRouter $router) {
         $router->enableFilter(['foo']);
         $router->get('profile', 'profile');
     });
     $this->setExpectedException(Exception::class, 'foo bar');
     $router->match(HttpRequestMethod::GET, new Url('profile'));
 }