File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed
Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 22 "strategy" : " semver" ,
33 "major" : 0 ,
44 "minor" : 8 ,
5- "patch" : 7 ,
5+ "patch" : 8 ,
66 "build" : 0
77}
Original file line number Diff line number Diff line change @@ -323,18 +323,19 @@ protected function loadRoutes(): void
323323 throw new Validation ( $ exception ->getMessage (), [] );
324324 }
325325
326- foreach ( $ Data [ 'routes ' ] as $ Route )
326+ foreach ( $ Data [ 'routes ' ] as $ RouteName => $ Route )
327327 {
328328 $ Request = $ Route [ 'request ' ] ?? '' ;
329329 $ Filter = $ Route [ 'filter ' ] ?? '' ;
330330
331- $ this ->addRoute (
331+ $ RouteMap = $ this ->addRoute (
332332 $ Route [ 'method ' ],
333333 $ Route [ 'route ' ],
334334 $ Route [ 'controller ' ],
335335 $ Request ,
336336 $ Filter
337337 );
338+ $ RouteMap ->setName ( $ RouteName );
338339 }
339340 }
340341
Original file line number Diff line number Diff line change @@ -397,4 +397,31 @@ public function testMissingControllerMethod()
397397
398398 $ this ->assertTrue ( $ this ->App ->getCrashed () );
399399 }
400+
401+ /**
402+ * Test that route names are loaded from YAML and set on RouteMap objects
403+ */
404+ public function testRouteNamesLoadedFromYaml ()
405+ {
406+ $ Router = $ this ->App ->getRouter ();
407+
408+ // Test that we can retrieve a route by its name from YAML
409+ $ LoginRoute = $ Router ->getRouteByName ( 'login ' );
410+
411+ $ this ->assertNotNull ( $ LoginRoute , 'Route "login" should be found by name ' );
412+ $ this ->assertEquals ( '/login ' , $ LoginRoute ->Path , 'Route path should match ' );
413+ $ this ->assertEquals ( 'login ' , $ LoginRoute ->Name , 'Route name should be set ' );
414+
415+ // Test another named route
416+ $ TestRoute = $ Router ->getRouteByName ( 'test ' );
417+
418+ $ this ->assertNotNull ( $ TestRoute , 'Route "test" should be found by name ' );
419+ $ this ->assertEquals ( '/test ' , $ TestRoute ->Path , 'Test route path should match ' );
420+ $ this ->assertEquals ( 'test ' , $ TestRoute ->Name , 'Test route name should be set ' );
421+
422+ // Test that a non-existent route returns null
423+ $ NonExistentRoute = $ Router ->getRouteByName ( 'nonexistent ' );
424+
425+ $ this ->assertNull ( $ NonExistentRoute , 'Non-existent route should return null ' );
426+ }
400427}
Original file line number Diff line number Diff line change 1+ ## 0.8.8 2025-11-11
2+ * Fixed named routes.
3+
14## 0.8.7 2025-11-10
25* Updated error handling.
36
You can’t perform that action at this time.
0 commit comments