diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
| commit | a61bcc830dfe801db7f94e01bbbe5a0b7b0a7dea (patch) | |
| tree | 6b8aaa7b06b6c4f442dd0d46255608b34b82a7a0 /tests/Unit/GroupTest.php | |
| parent | 6ad39e3ba64e518bcdba1fc32b6247375be39a8a (diff) | |
getting parents and path from group and testing
Diffstat (limited to 'tests/Unit/GroupTest.php')
| -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'); |
