File tree 3 files changed +43
-1
lines changed
user_guide_src/source/changelogs
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
57
57
$ handler = $ view ? '(View) ' . $ view : '(Closure) ' ;
58
58
}
59
59
60
- $ routeName = $ this ->routeCollection ->getRoutesOptions ($ route )['as ' ] ?? $ route ;
60
+ $ routeName = $ this ->routeCollection ->getRoutesOptions ($ route, $ method )['as ' ] ?? $ route ;
61
61
62
62
yield [
63
63
'method ' => $ method ,
Original file line number Diff line number Diff line change @@ -87,4 +87,45 @@ public function testCollect()
87
87
];
88
88
$ this ->assertSame ($ expected , $ definedRoutes );
89
89
}
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
+ }
90
131
}
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ Bugs Fixed
46
46
production mode or to display backtrace in json when an exception occurred.
47
47
- **Forge: ** Fixed a bug where adding a Primary Key to an existing table was
48
48
ignored if there were no other Keys added too.
49
+ - **Routing: ** Fixed a bug that ``spark routes `` may show incorrect route names.
49
50
50
51
See the repo's
51
52
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md >`_
You can’t perform that action at this time.
0 commit comments