TYPO3 CMS  TYPO3_7-6
AbstractHierarchicalFilesystemDriverTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
28  protected $subject = null;
29 
30  protected function setUp()
31  {
32  parent::setUp();
33  $this->subject = $this->getAccessibleMockForAbstractClass(AbstractHierarchicalFilesystemDriver::class, [], '', false);
34  }
35 
42  public function canonicalizeAndCheckFileIdentifierCanonicalizesPath($expectedPath, $fileIdentifier)
43  {
44  $this->assertSame($expectedPath, $this->subject->_callRef('canonicalizeAndCheckFileIdentifier', $fileIdentifier));
45  }
46 
51  {
52  return [
53  'File path gets leading slash' => [
54  '/foo.php',
55  'foo.php',
56  ],
57  'Absolute path to file is not modified' => [
58  '/bar/foo.php',
59  '/bar/foo.php',
60  ],
61  'Relative path to file gets leading slash' => [
62  '/bar/foo.php',
63  'bar/foo.php',
64  ],
65  'Empty string is returned as empty string' => [
66  '',
67  '',
68  ],
69  'Double slashes in path are removed' => [
70  '/bar/foo.php',
71  '/bar//foo.php',
72  ],
73  'Trailing point in path is removed' => [
74  '/foo.php',
75  './foo.php',
76  ],
77  'Point is replaced by slash' => [
78  '/',
79  '.',
80  ],
81  './ becomes /' => [
82  '/',
83  './',
84  ]
85  ];
86  }
87 
94  public function canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier($expectedPath, $identifier)
95  {
96  $this->assertSame($expectedPath, $this->subject->_callRef('canonicalizeAndCheckFolderIdentifier', $identifier));
97  }
98 
103  {
104  return [
105  'Empty string results in slash' => [
106  '/',
107  '',
108  ],
109  'Single point results in slash' => [
110  '/',
111  '.',
112  ],
113  'Single slash results in single slash' => [
114  '/',
115  '/',
116  ],
117  'Double slash results in single slash' => [
118  '/',
119  '//',
120  ],
121  'Absolute folder paths without trailing slash gets a trailing slash' => [
122  '/foo/',
123  '/foo',
124  ],
125  'Absolute path with trailing and leading slash is not modified' => [
126  '/foo/',
127  '/foo/',
128  ],
129  'Relative path to folder becomes absolute path with trailing slash' => [
130  '/foo/',
131  'foo/',
132  ],
133  ];
134  }
135 }
getAccessibleMockForAbstractClass( $originalClassName, array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true, $mockedMethods=[])