Skip to content

Commit 5af603c

Browse files
committed
test: add test
1 parent ce62326 commit 5af603c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/system/Router/DefinedRouteCollectorTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)