Skip to content

Commit

Permalink
test: add test for multiple nested groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed May 1, 2023
1 parent f2e5694 commit a079a93
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/groups.test.php
Expand Up @@ -102,3 +102,24 @@ class TGroup

expect(TGroup::$val)->toBe(false);
});

test('route groups support multiple nested groups', function () {
$_SERVER['REQUEST_URI'] = '/group/nested/route';

$rx2 = new Router;

$rx2->mount('/group', function () use ($rx2) {
$rx2->mount('/nested', function () use ($rx2) {
$rx2->get('/route', function () {});
});

$rx2->mount('/nested2', function () use ($rx2) {
$rx2->get('/route', function () {});
});
});

$rx2Routes = $rx2->routes();

expect($rx2Routes)->toBeArray();
expect($rx2Routes[count($rx2Routes) - 1]['pattern'] ?? null)->toBe('/group/nested2/route');
});

0 comments on commit a079a93

Please sign in to comment.