‪TYPO3CMS  11.5
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\MockObject\MockObject;
23 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
24 
29 {
33  protected ‪$subject;
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38  $this->subject = $this->getAccessibleMockForAbstractClass(AbstractHierarchicalFilesystemDriver::class, [], '', false);
39  }
40 
47  public function ‪canonicalizeAndCheckFileIdentifierCanonicalizesPath(string $expectedPath, string $fileIdentifier): void
48  {
49  self::assertSame($expectedPath, $this->subject->_call('canonicalizeAndCheckFileIdentifier', $fileIdentifier));
50  }
51 
56  {
57  return [
58  'File path gets leading slash' => [
59  '/foo.php',
60  'foo.php',
61  ],
62  'Absolute path to file is not modified' => [
63  '/bar/foo.php',
64  '/bar/foo.php',
65  ],
66  'Relative path to file gets leading slash' => [
67  '/bar/foo.php',
68  'bar/foo.php',
69  ],
70  'Empty string is returned as empty string' => [
71  '',
72  '',
73  ],
74  'Double slashes in path are removed' => [
75  '/bar/foo.php',
76  '/bar//foo.php',
77  ],
78  'Trailing point in path is removed' => [
79  '/foo.php',
80  './foo.php',
81  ],
82  'Point is replaced by slash' => [
83  '/',
84  '.',
85  ],
86  './ becomes /' => [
87  '/',
88  './',
89  ],
90  ];
91  }
92 
99  public function ‪canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier(string $expectedPath, string $identifier): void
100  {
101  self::assertSame($expectedPath, $this->subject->_call('canonicalizeAndCheckFolderIdentifier', $identifier));
102  }
103 
108  {
109  return [
110  'Empty string results in slash' => [
111  '/',
112  '',
113  ],
114  'Single point results in slash' => [
115  '/',
116  '.',
117  ],
118  'Single slash results in single slash' => [
119  '/',
120  '/',
121  ],
122  'Double slash results in single slash' => [
123  '/',
124  '//',
125  ],
126  'Absolute folder paths without trailing slash gets a trailing slash' => [
127  '/foo/',
128  '/foo',
129  ],
130  'Absolute path with trailing and leading slash is not modified' => [
131  '/foo/',
132  '/foo/',
133  ],
134  'Relative path to folder becomes absolute path with trailing slash' => [
135  '/foo/',
136  'foo/',
137  ],
138  ];
139  }
140 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\$subject
‪AbstractHierarchicalFilesystemDriver MockObject AccessibleObjectInterface $subject
Definition: AbstractHierarchicalFilesystemDriverTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest
Definition: AbstractHierarchicalFilesystemDriverTest.php:29
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver
Definition: AbstractHierarchicalFilesystemDriver.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase
Definition: BaseTestCase.php:31
‪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:98
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFileIdentifierCanonicalizesPathDataProvider
‪array canonicalizeAndCheckFileIdentifierCanonicalizesPathDataProvider()
Definition: AbstractHierarchicalFilesystemDriverTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider
‪array canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider()
Definition: AbstractHierarchicalFilesystemDriverTest.php:106
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\canonicalizeAndCheckFileIdentifierCanonicalizesPath
‪canonicalizeAndCheckFileIdentifierCanonicalizesPath(string $expectedPath, string $fileIdentifier)
Definition: AbstractHierarchicalFilesystemDriverTest.php:46
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\AbstractHierarchicalFilesystemDriverTest\setUp
‪setUp()
Definition: AbstractHierarchicalFilesystemDriverTest.php:34