Skip to content

Commit

Permalink
test: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 26, 2022
1 parent d5b5224 commit 106eda3
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions tests/system/Router/RouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,19 @@ static function ($routes) {
$this->assertSame($expected, $routes->getRoutes());
}

public function testNestedGroupingWorksWithRootPrefix()
{
/**
* @dataProvider groupProvider
*/
public function testNestedGroupingWorksWithRootPrefix(
string $group,
string $subgroup,
array $expected
) {
$routes = $this->getCollector();

$routes->add('verify/begin', '\VerifyController::begin');

$routes->group('admin', static function ($routes) {
$routes->group($group, static function ($routes) use ($subgroup) {
$routes->group(
'/',
$subgroup,
static function ($routes) {
$routes->add('users/list', '\Users::list');

Expand All @@ -394,15 +398,31 @@ static function ($routes) {
);
});

$expected = [
'verify/begin' => '\VerifyController::begin',
'admin/users/list' => '\Users::list',
'admin/delegate/foo' => '\Users::foo',
];

$this->assertSame($expected, $routes->getRoutes());
}

public function groupProvider()
{
yield from [
['admin', '/', [
'admin/users/list' => '\Users::list',
'admin/delegate/foo' => '\Users::foo',
]],
['/', '', [
'users/list' => '\Users::list',
'delegate/foo' => '\Users::foo',
]],
['', '', [
'users/list' => '\Users::list',
'delegate/foo' => '\Users::foo',
]],
['', '/', [
'users/list' => '\Users::list',
'delegate/foo' => '\Users::foo',
]],
];
}

public function testHostnameOption()
{
$_SERVER['HTTP_HOST'] = 'example.com';
Expand Down

0 comments on commit 106eda3

Please sign in to comment.