From dc03419384af6def0b3adb3b976b1f5a3a46cca2 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: Make route from route string --- tests/Unit/PathSegmentTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/Unit/PathSegmentTest.php b/tests/Unit/PathSegmentTest.php index 29abb8c..0606b75 100644 --- a/tests/Unit/PathSegmentTest.php +++ b/tests/Unit/PathSegmentTest.php @@ -56,6 +56,20 @@ it('gets type :dataset', function (PathSegmentType $type) { } }); +it('is made from route string :dataset', function (string $v, PathSegmentType $type) { + $seg = PathSegment::makeFromRouteString($v); + expect($seg->getType())->toBe($type); +})->with([ + $v = '{test-test}' => [$v, PathSegmentType::Parameter], + $v = '{test_test}' => [$v, PathSegmentType::Parameter], + $v = '{testTest}' => [$v, PathSegmentType::Parameter], + $v = '{TestTest}' => [$v, PathSegmentType::Parameter], + $v = '{testTest912}' => [$v, PathSegmentType::Parameter], + $v = 'hello-hello' => [$v, PathSegmentType::Raw], + $v = 'hellohello123' => [$v, PathSegmentType::Raw], + $v = 'hello_hello' => [$v, PathSegmentType::Raw], +]); + it('defaults type to Raw') ->expect(fn () => (new PathSegment('testing'))->getType()) ->toBe(PathSegmentType::Raw); -- cgit v1.2.3