Skip to content

Commit

Permalink
test: add test for nested dynamic groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed May 1, 2023
1 parent f6e899d commit b0e065f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/groups.test.php
Expand Up @@ -124,3 +124,23 @@ class TGroup
expect($rx2Routes[count($rx2Routes) - 2]['pattern'] ?? null)->toBe('/group/nested/route');
expect($rx2Routes[count($rx2Routes) - 1]['pattern'] ?? null)->toBe('/group/nested2/route');
});

test('dynamic nested route groups', function () {
$_SERVER['REQUEST_URI'] = '/hiddenGroup/1/route';

$rx = new Router;

TGroup::$val = true;

$rx->mount('/hiddenGroup', function () use ($rx) {
$rx->mount('/(\d+)', function () use ($rx) {
$rx->get('/route', function () use ($rx) {
TGroup::$val = 'Hidden response';
});
});
});

$rx->run();

expect(TGroup::$val)->toBe('Hidden response');
});

0 comments on commit b0e065f

Please sign in to comment.