|
9 | 9 |
|
10 | 10 | final class UrlGeneratorTest extends TestCase |
11 | 11 | { |
| 12 | + #[DataProvider('fileUrlProvider')] |
| 13 | + public function testCreateFileUrl(string $expected, string $filename, string $outputFormat = 'html', string|null $anchor = null, string $skip = ''): void |
| 14 | + { |
| 15 | + if ($skip !== '') { |
| 16 | + self::markTestSkipped($skip); |
| 17 | + } |
| 18 | + |
| 19 | + $urlGenerator = new UrlGenerator(); |
| 20 | + self::assertSame($expected, $urlGenerator->createFileUrl($filename, $outputFormat, $anchor)); |
| 21 | + } |
| 22 | + |
| 23 | + /** @return array<string, array<string, string|null>> */ |
| 24 | + public static function fileUrlProvider(): array |
| 25 | + { |
| 26 | + return [ |
| 27 | + 'Simple Filename' => [ |
| 28 | + 'expected' => 'file.html', |
| 29 | + 'filename' => 'file', |
| 30 | + ], |
| 31 | + 'Complex Filename' => [ |
| 32 | + 'expected' => 'file-something.html', |
| 33 | + 'filename' => 'file-something', |
| 34 | + ], |
| 35 | + 'Output Format' => [ |
| 36 | + 'expected' => 'texfile.tex', |
| 37 | + 'filename' => 'texfile', |
| 38 | + 'outputFormat' => 'tex', |
| 39 | + ], |
| 40 | + 'File with anchor' => [ |
| 41 | + 'expected' => 'file.html#anchor', |
| 42 | + 'filename' => 'file', |
| 43 | + 'outputFormat' => 'html', |
| 44 | + 'anchor' => 'anchor', |
| 45 | + ], |
| 46 | + 'Empty File with anchor' => [ |
| 47 | + 'expected' => '#anchor', |
| 48 | + 'filename' => '', |
| 49 | + 'outputFormat' => 'html', |
| 50 | + 'anchor' => 'anchor', |
| 51 | + 'skip' => 'Empty filenames are not supported', |
| 52 | + ], |
| 53 | + 'Empty File with empty anchor' => [ |
| 54 | + 'expected' => '#', |
| 55 | + 'filename' => '', |
| 56 | + 'outputFormat' => 'html', |
| 57 | + 'anchor' => null, |
| 58 | + 'skip' => 'Empty filenames are not supported', |
| 59 | + ], |
| 60 | + ]; |
| 61 | + } |
| 62 | + |
12 | 63 | #[DataProvider('canonicalUrlProvider')] |
13 | 64 | public function testCanonicalUrl(string $basePath, string $url, string $result): void |
14 | 65 | { |
@@ -86,10 +137,4 @@ public static function abstractUrlProvider(): array |
86 | 137 | ], |
87 | 138 | ]; |
88 | 139 | } |
89 | | - |
90 | | - public function testUrlGenerationOfInvalidUrlReturnsInput(): void |
91 | | - { |
92 | | - $urlGenerator = new UrlGenerator(); |
93 | | - self::assertSame('tcp://hostname:port', $urlGenerator->generateUrl('tcp://hostname:port')); |
94 | | - } |
95 | 140 | } |
0 commit comments