diff options
Diffstat (limited to 'tests/Unit')
| -rw-r--r-- | tests/Unit/GroupTest.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/Unit/GroupTest.php b/tests/Unit/GroupTest.php index 3b17f19..6549295 100644 --- a/tests/Unit/GroupTest.php +++ b/tests/Unit/GroupTest.php @@ -7,7 +7,7 @@ use Lightscale\Router\GroupDefinition; use Lightscale\Router\Router; use Lightscale\Router\Test\Utils\TestCallable; -$make = fn(?Group $parent = null, ...$args) => new Group(new Router, $parent, ...$args); +$make = fn(?Group $parent = null) => new Group(new Router, $parent); it('initializes with null defaults') ->expect(fn() => $make()) @@ -79,3 +79,34 @@ it('order all ancestors and self root first', function () use($make) { ->{1}->toBe($g2) ->{2}->toBe($g3); }); + +it('gets the path with no prefix or parents') + ->expect(fn () => $make()->getPath()) + ->toBe('/'); + +it('gets the path without parents') + ->expect(fn () => $make()->prefix('/t1/t2')->getPath()) + ->toBe('/t1/t2'); + +it('gets the path with parent') + ->expect(fn () => $make( + $make()->prefix('hello/world') + )->prefix('/t1/t2')->getPath()) + ->toBe('/hello/world/t1/t2'); + +it('gets the path with two ancestors') + ->expect(fn () => $make( + $make( + $make()->prefix('test') + )->prefix('hello/world') + )->prefix('/t1/t2')->getPath()) + ->toBe('/test/hello/world/t1/t2'); + + +it('gets the path with three ancestors, one without prefix') + ->expect(fn () => $make( + $make( + $make($make()->prefix('test')) + )->prefix('hello/world') + )->prefix('/t1/t2')->getPath()) + ->toBe('/test/hello/world/t1/t2'); |
