From 6a8c20e1ca74d0649bf3a79e5bbb885506492120 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 19 Jun 2023 17:08:12 +0900 Subject: [PATCH 1/2] test: add test to check param count is reset --- tests/system/Test/FeatureTestAutoRoutingImprovedTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php index 897697146fb5..19481a2860d3 100644 --- a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php +++ b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php @@ -72,4 +72,13 @@ public function testCallPost() $response->assertSee('Saved'); } + + public function testCallParamsCount() + { + $response = $this->post('newautorouting/save/1/a/b'); + $response->assertSee('Saved'); + + $response = $this->get('newautorouting'); + $response->assertSee('Hello'); + } } From f39530ac57c747bb7bffbbcbed8df84374145733 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 19 Jun 2023 17:09:07 +0900 Subject: [PATCH 2/2] fix: reset params for HTTP testing A previous test result causes an params count error in HTTP testing. --- system/Router/AutoRouterImproved.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/Router/AutoRouterImproved.php b/system/Router/AutoRouterImproved.php index 6f2aa1af5ece..42fe18e937af 100644 --- a/system/Router/AutoRouterImproved.php +++ b/system/Router/AutoRouterImproved.php @@ -106,6 +106,9 @@ public function getRoute(string $uri, string $httpVerb): array { $httpVerb = strtolower($httpVerb); + // Reset Controller method params. + $this->params = []; + $defaultMethod = $httpVerb . ucfirst($this->defaultMethod); $this->method = $defaultMethod;