Skip to content

Commit 106eda3

Browse files
committed
test: add test cases
1 parent d5b5224 commit 106eda3

1 file changed

Lines changed: 32 additions & 12 deletions

File tree

tests/system/Router/RouteCollectionTest.php

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,19 @@ static function ($routes) {
375375
$this->assertSame($expected, $routes->getRoutes());
376376
}
377377

378-
public function testNestedGroupingWorksWithRootPrefix()
379-
{
378+
/**
379+
* @dataProvider groupProvider
380+
*/
381+
public function testNestedGroupingWorksWithRootPrefix(
382+
string $group,
383+
string $subgroup,
384+
array $expected
385+
) {
380386
$routes = $this->getCollector();
381387

382-
$routes->add('verify/begin', '\VerifyController::begin');
383-
384-
$routes->group('admin', static function ($routes) {
388+
$routes->group($group, static function ($routes) use ($subgroup) {
385389
$routes->group(
386-
'/',
390+
$subgroup,
387391
static function ($routes) {
388392
$routes->add('users/list', '\Users::list');
389393

@@ -394,15 +398,31 @@ static function ($routes) {
394398
);
395399
});
396400

397-
$expected = [
398-
'verify/begin' => '\VerifyController::begin',
399-
'admin/users/list' => '\Users::list',
400-
'admin/delegate/foo' => '\Users::foo',
401-
];
402-
403401
$this->assertSame($expected, $routes->getRoutes());
404402
}
405403

404+
public function groupProvider()
405+
{
406+
yield from [
407+
['admin', '/', [
408+
'admin/users/list' => '\Users::list',
409+
'admin/delegate/foo' => '\Users::foo',
410+
]],
411+
['/', '', [
412+
'users/list' => '\Users::list',
413+
'delegate/foo' => '\Users::foo',
414+
]],
415+
['', '', [
416+
'users/list' => '\Users::list',
417+
'delegate/foo' => '\Users::foo',
418+
]],
419+
['', '/', [
420+
'users/list' => '\Users::list',
421+
'delegate/foo' => '\Users::foo',
422+
]],
423+
];
424+
}
425+
406426
public function testHostnameOption()
407427
{
408428
$_SERVER['HTTP_HOST'] = 'example.com';

0 commit comments

Comments
 (0)