def test_can_make_route_group_nested(self): router = Router( Route.group( Route.get("/group", "WelcomeController@show"), Route.post("/login", "WelcomeController@show"), Route.group( Route.get("/api/user", "WelcomeController@show"), Route.group(Route.get("/api/test", None), prefix="/v1"), ), prefix="/testing", )) route = router.find("/testing/api/user", "GET") self.assertTrue(route) route = router.find("/testing/v1/api/test", "GET") self.assertTrue(route)
def test_can_add_routes(self): routes = Route.group([ Route.get("/home", "WelcomeController"), Route.post("/login", "WelcomeController"), ]) self.assertEqual(len(routes), 2)
def test_can_make_route_group(self): router = Router( Route.group( Route.get("/group", "WelcomeController@show"), Route.post("/login", "WelcomeController@show"), prefix="/testing", )) route = router.find("/testing/group", "GET") self.assertTrue(route)
def register_routes(self): Route.set_controller_locations( self.application.make("controllers.location")) self.application.bind("routes.location", "tests/integrations/web") self.application.make("router").add( Route.group( load(self.application.make("routes.location"), "ROUTES", []), middleware=["web"], ))
def test_can_make_base_route_group(self): router = Router( Route.group( [ Route.get("", "WelcomeController@show"), ], prefix="/testing", )) route = router.find("/testing", "GET") self.assertTrue(route)
def test_group_naming(self): router = Router( Route.group( Route.get("/group", "WelcomeController@show").name(".index"), Route.post("/login", "WelcomeController@show").name(".index"), prefix="/testing", name="dashboard", )) route = router.find_by_name("dashboard.index") self.assertTrue(route)