From d327950f175fff6a1d95b1b95ee2e761b895de2c Mon Sep 17 00:00:00 2001 From: Rotimi Ade Date: Sat, 1 Mar 2025 20:33:46 -0700 Subject: [PATCH] Updated tests for actionRoutes --- ...oller-classes-by-action-methods-report.php | 8 +++-- tests/AllRoutesTest.php | 30 ++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/views/base/controller-classes-by-action-methods-report.php b/src/views/base/controller-classes-by-action-methods-report.php index f51c1be..33c05f1 100644 --- a/src/views/base/controller-classes-by-action-methods-report.php +++ b/src/views/base/controller-classes-by-action-methods-report.php @@ -119,7 +119,7 @@ function(\ReflectionMethod $current_method)use($functionStrStartsWith, $rfclass, if ( count($action_methods_by_controller_class_name) > 0 ) { foreach ( $action_methods_by_controller_class_name as $controller_class_name=>$action_methods ) { - + foreach ( $action_methods as $action_method ) { $ref_meth_obj = $reflection_methods_map["{$controller_class_name}:{$action_method}"]; @@ -133,7 +133,11 @@ function(\ReflectionMethod $current_method)use($functionStrStartsWith, $rfclass, ? str_replace('action', '', $ref_meth_obj->getName()) : $ref_meth_obj->getName() ) - : camelToDashes($ref_meth_obj->getName()) + : camelToDashes( + $stripActionPrefixFromMethodName + ? str_replace('action', '', $ref_meth_obj->getName()) + : $ref_meth_obj->getName() + ) ); foreach ($ref_meth_obj->getParameters() as $parameter) { diff --git a/tests/AllRoutesTest.php b/tests/AllRoutesTest.php index d5237e6..d9cb530 100644 --- a/tests/AllRoutesTest.php +++ b/tests/AllRoutesTest.php @@ -607,7 +607,7 @@ public function testBaseControllerActionRoutes() { // Should contain the /base-controller/action-routes/0/0 page $response_body2 = ((string)$response2->getBody()); - + $expected_output1 = <<
@@ -705,6 +705,11 @@ public function testBaseControllerActionRoutes() { SlimMvcTools\Controllers\BaseController forceHttp410 base-controller/force-http410/message[/request=NULL] + + + SlimMvcTools\Controllers\BaseController + forceHttp429 + base-controller/force-http429/message[/request=NULL] SlimMvcTools\Controllers\BaseController @@ -969,27 +974,27 @@ public function testBaseControllerActionRoutes() { SlimMvcTools\Controllers\BaseController actionIndex - base-controller/action-index + base-controller/index SlimMvcTools\Controllers\BaseController actionLogin - base-controller/action-login + base-controller/login SlimMvcTools\Controllers\BaseController actionLoginStatus - base-controller/action-login-status + base-controller/login-status SlimMvcTools\Controllers\BaseController actionLogout - base-controller/action-logout[/show_status_on_completion=false] + base-controller/logout[/show_status_on_completion=false] SlimMvcTools\Controllers\BaseController actionRoutes - base-controller/action-routes[/onlyPublicMethodsPrefixedWithAction=true][/stripActionPrefixFromMethodName=true] + base-controller/routes[/onlyPublicMethodsPrefixedWithAction=true][/stripActionPrefixFromMethodName=true] SlimMvcTools\Controllers\BaseController @@ -1020,6 +1025,11 @@ public function testBaseControllerActionRoutes() { SlimMvcTools\Controllers\BaseController forceHttp410 base-controller/force-http410/message[/request=NULL] + + + SlimMvcTools\Controllers\BaseController + forceHttp429 + base-controller/force-http429/message[/request=NULL] SlimMvcTools\Controllers\BaseController @@ -1197,22 +1207,22 @@ public function testBaseControllerActionRoutes() { SlimSkeletonMvcApp\Controllers\Hello actionForceHttpFourxxOrFivexx - hello/action-force-http-fourxx-or-fivexx[/http_code=400] + hello/force-http-fourxx-or-fivexx[/http_code=400] SlimSkeletonMvcApp\Controllers\Hello actionIndex - hello/action-index + hello/index SlimSkeletonMvcApp\Controllers\Hello actionThere - hello/action-there/first_name/last_name + hello/there/first_name/last_name SlimSkeletonMvcApp\Controllers\Hello actionWorld - hello/action-world/name/another_param + hello/world/name/another_param