summaryrefslogtreecommitdiff
path: root/tests/Unit/Enums/PathSegmentTypeTest.php
blob: a0a638dab2af106bb71d35ed9e1e502c2ff4440f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

declare(strict_types=1);

use Lightscale\Router\Enums\PathSegmentType;

it('has no routeMatchRegex for Raw')
    ->expect(fn () => PathSegmentType::Raw->routeMatchRegex())
    ->toBeNull();

it('has no routeMatchRegex for Root')
    ->expect(fn () => PathSegmentType::Root->routeMatchRegex())
    ->toBeNull();

it('has routeMatchRegex for Parameter')
    ->expect(fn () => PathSegmentType::Parameter->routeMatchRegex())
    ->toBeString();

it('matches from route string :dataset', function (string $v, PathSegmentType $type) {
    $match = PathSegmentType::matchRouteString($v);
    expect($match->type)->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],
]);