Ejemplo n.º 1
0
 public function testEmptyURIMatchesDefaults()
 {
     $router = new Router($this->collection);
     $router->handle('');
     $this->assertEquals($this->collection->getDefaultController(), $router->controllerName());
     $this->assertEquals($this->collection->getDefaultMethod(), $router->methodName());
 }
 /**
  * @group single
  */
 public function testReverseRoutingThrowsExceptionWithBadParamTypes()
 {
     $map = ['path/(:any)/to/(:num)' => 'myController::goto/$1/$2'];
     $collection = new RouteCollection();
     $collection->map($map);
     $this->setExpectedException('LogicException');
     $match = $collection->reverseRoute('myController::goto', 13, 'string');
 }
Ejemplo n.º 3
0
 public function testRun404OverrideByClosure()
 {
     $_SERVER['argv'] = ['index.php', '/'];
     $_SERVER['argc'] = 2;
     // Inject mock router.
     $routes = new RouteCollection();
     $routes->setAutoRoute(false);
     $routes->set404Override(function () {
         echo '404 Override by Closure.';
     });
     $router = Services::router($routes);
     Services::injectMock('router', $router);
     ob_start();
     $this->codeigniter->run($routes);
     $output = ob_get_clean();
     $this->assertContains('404 Override by Closure.', $output);
 }