コード例 #1
0
ファイル: RouterTest.php プロジェクト: titounnes/CodeIgniter4
 public function setUp()
 {
     $this->collection = new RouteCollection();
     $routes = ['users' => 'Users::index', 'posts' => 'Blog::posts', 'pages' => 'App\\Pages::list_all', 'posts/(:num)' => 'Blog::show/$1', 'posts/(:num)/edit' => 'Blog::edit/$1', 'books/(:num)/(:alpha)/(:num)' => 'Blog::show/$3/$1', 'closure/(:num)/(:alpha)' => function ($num, $str) {
         return $num . '-' . $str;
     }];
     $this->collection->map($routes);
 }
コード例 #2
0
 /**
  * @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');
 }