‪TYPO3CMS  ‪main
AbstractHierarchicalFilesystemDriverTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪AbstractHierarchicalFilesystemDriverTest extends UnitTestCase
26 {
28  {
29  return [
30  'File path gets leading slash' => [
31  '/foo.php',
32  'foo.php',
33  ],
34  'Absolute path to file is not modified' => [
35  '/bar/foo.php',
36  '/bar/foo.php',
37  ],
38  'Relative path to file gets leading slash' => [
39  '/bar/foo.php',
40  'bar/foo.php',
41  ],
42  'Empty string is returned as empty string' => [
43  '',
44  '',
45  ],
46  'Double slashes in path are removed' => [
47  '/bar/foo.php',
48  '/bar//foo.php',
49  ],
50  'Trailing point in path is removed' => [
51  '/foo.php',
52  './foo.php',
53  ],
54  'Point is replaced by slash' => [
55  '/',
56  '.',
57  ],
58  './ becomes /' => [
59  '/',
60  './',
61  ],
62  ];
63  }
64 
65  #[DataProvider('canonicalizeAndCheckFileIdentifierCanonicalizesPathDataProvider')]
66  #[Test]
67  public function ‪canonicalizeAndCheckFileIdentifierCanonicalizesPath(string $expectedPath, string $fileIdentifier): void
68  {
70  self::assertSame($expectedPath, $subject->canonicalizeAndCheckFileIdentifier($fileIdentifier));
71  }
72 
74  {
75  return [
76  'Empty string results in slash' => [
77  '/',
78  '',
79  ],
80  'Single point results in slash' => [
81  '/',
82  '.',
83  ],
84  'Single slash results in single slash' => [
85  '/',
86  '/',
87  ],
88  'Double slash results in single slash' => [
89  '/',
90  '//',
91  ],
92  'Absolute folder paths without trailing slash gets a trailing slash' => [
93  '/foo/',
94  '/foo',
95  ],
96  'Absolute path with trailing and leading slash is not modified' => [
97  '/foo/',
98  '/foo/',
99  ],
100  'Relative path to folder becomes absolute path with trailing slash' => [
101  '/foo/',
102  'foo/',
103  ],
104  ];
105  }
106 
107  #[DataProvider('canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider')]
108  #[Test]
110  {
112  self::assertSame($expectedPath, $subject->canonicalizeAndCheckFolderIdentifier(‪$identifier));
113  }
114 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider
‪static canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider()
Definition: AbstractHierarchicalFilesystemDriverTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest
Definition: AbstractHierarchicalFilesystemDriverTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver
Definition: AbstractDriverTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier
‪canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier(string $expectedPath, string $identifier)
Definition: AbstractHierarchicalFilesystemDriverTest.php:109
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFileIdentifierCanonicalizesPathDataProvider
‪static canonicalizeAndCheckFileIdentifierCanonicalizesPathDataProvider()
Definition: AbstractHierarchicalFilesystemDriverTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFileIdentifierCanonicalizesPath
‪canonicalizeAndCheckFileIdentifierCanonicalizesPath(string $expectedPath, string $fileIdentifier)
Definition: AbstractHierarchicalFilesystemDriverTest.php:67
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\TestingHierarchicalFilesystemDriver
Definition: TestingHierarchicalFilesystemDriver.php:27
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37