packages/requirements/tests/Unit/Config/Markdown/LocalPathTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Config\Markdown;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\DataProvider;
9use PHPUnit\Framework\Attributes\Small;
10use PHPUnit\Framework\TestCase;
11use Requirements\Config\Markdown\LocalPath;
12
13#[CoversClass(LocalPath::class)]
14#[Small]
15final class LocalPathTest extends TestCase
16{
17 #[DataProvider('providerNormalize')]
18 public function testNormalizeResolvesDotsAndSeparators(string $path, string $expected): void
19 {
20 self::assertSame($expected, LocalPath::normalize($path));
21 }
22
23 /**
24 * @return array<string, array{string, string}>
25 */
26 public static function providerNormalize(): array
27 {
28 return [
29 'plain' => ['a/b.md', 'a/b.md'],
30 'current directory and repeated separators' => ['a/./b//c/', 'a/b/c'],
31 'parent directory' => ['/project/definitions/../source.html', 'project/source.html'],
32 'backslashes' => ['a\\b\\..\\c', 'a/c'],
33 'parent above the start' => ['../a', 'a'],
34 'empty' => ['', ''],
35 'only separators' => ['/./', ''],
36 ];
37 }
38}
39