ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
ContainerManagerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\Attributes\DataProvider;
24use PHPUnit\Framework\TestCase;
25
29final class ContainerManagerTest extends TestCase
30{
36 #[DataProvider('pathProvider')]
37 public function testNormalizePathProducesRelativePath(string $input, string $expected): void
38 {
39 $manager = (new \ReflectionClass(ContainerManager::class))->newInstanceWithoutConstructor();
40 $method = new \ReflectionMethod(ContainerManager::class, 'normalizePath');
41
42 $this->assertSame($expected, $method->invoke($manager, $input));
43 }
44
45 public static function pathProvider(): \Iterator
46 {
47 yield 'file at root, no prefix' => ['index.html', 'index.html'];
48 yield 'file at root, leading slash' => ['/index.html', 'index.html'];
49 yield 'file at root, dot-slash' => ['./index.html', 'index.html'];
50 yield 'file in subdir, no prefix' => ['dir/file.html', 'dir/file.html'];
51 yield 'file in subdir, leading slash' => ['/dir/file.html', 'dir/file.html'];
52 yield 'nested file, leading slash' => ['/assets/css/style.css', 'assets/css/style.css'];
53 yield 'nested file, no prefix' => ['assets/css/style.css', 'assets/css/style.css'];
54 yield 'trailing slash preserved as empty' => ['/', ''];
55 yield 'empty input' => ['', ''];
56 yield 'directory with trailing slash' => ['dir/', 'dir'];
57 yield 'directory with both slashes' => ['/dir/', 'dir'];
58 }
59}
testNormalizePathProducesRelativePath(string $input, string $expected)
Regression for Mantis 0045580 / 0047237: paths inside ZIP containers must be stored as relative paths...