File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
user_guide_src/source/changelogs Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function collect(): Generator
5757 $ handler = $ view ? '(View) ' . $ view : '(Closure) ' ;
5858 }
5959
60- $ routeName = $ this ->routeCollection ->getRoutesOptions ($ route )['as ' ] ?? $ route ;
60+ $ routeName = $ this ->routeCollection ->getRoutesOptions ($ route, $ method )['as ' ] ?? $ route ;
6161
6262 yield [
6363 'method ' => $ method ,
Original file line number Diff line number Diff line change @@ -87,4 +87,45 @@ public function testCollect()
8787 ];
8888 $ this ->assertSame ($ expected , $ definedRoutes );
8989 }
90+
91+ /**
92+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/8039
93+ */
94+ public function testCollectSameFromWithDifferentVerb ()
95+ {
96+ $ routes = $ this ->createRouteCollection ();
97+ $ routes ->get ('login ' , 'AuthController::showLogin ' , ['as ' => 'loginShow ' ]);
98+ $ routes ->post ('login ' , 'AuthController::login ' , ['as ' => 'login ' ]);
99+ $ routes ->get ('logout ' , 'AuthController::logout ' , ['as ' => 'logout ' ]);
100+
101+ $ collector = new DefinedRouteCollector ($ routes );
102+
103+ $ definedRoutes = [];
104+
105+ foreach ($ collector ->collect () as $ route ) {
106+ $ definedRoutes [] = $ route ;
107+ }
108+
109+ $ expected = [
110+ [
111+ 'method ' => 'get ' ,
112+ 'route ' => 'login ' ,
113+ 'name ' => 'loginShow ' ,
114+ 'handler ' => '\\App \\Controllers \\AuthController::showLogin ' ,
115+ ],
116+ [
117+ 'method ' => 'get ' ,
118+ 'route ' => 'logout ' ,
119+ 'name ' => 'logout ' ,
120+ 'handler ' => '\\App \\Controllers \\AuthController::logout ' ,
121+ ],
122+ [
123+ 'method ' => 'post ' ,
124+ 'route ' => 'login ' ,
125+ 'name ' => 'login ' ,
126+ 'handler ' => '\\App \\Controllers \\AuthController::login ' ,
127+ ],
128+ ];
129+ $ this ->assertSame ($ expected , $ definedRoutes );
130+ }
90131}
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ Bugs Fixed
4646 production mode or to display backtrace in json when an exception occurred.
4747- **Forge: ** Fixed a bug where adding a Primary Key to an existing table was
4848 ignored if there were no other Keys added too.
49+ - **Routing: ** Fixed a bug that ``spark routes `` may show incorrect route names.
4950
5051See the repo's
5152`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md >`_
You can’t perform that action at this time.
0 commit comments