[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / ResourceUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Utility;
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
17 use TYPO3\CMS\Core\Utility\ResourceUtility;
18
19 /**
20 * Testcase for class \TYPO3\CMS\Core\Utility\ResourceUtility
21 */
22 class ResourceUtilityTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
23 {
24 /**
25 * @return array
26 */
27 public function recursiveFileListSortingHelperTestDataProvider()
28 {
29 return [
30 'normal file list' => [
31 ['fileB', 'fileA', 'someFile'],
32 ['fileA', 'fileB', 'someFile']
33 ],
34 'already in correct order' => [
35 ['fileA', 'fileB', 'someFile'],
36 ['fileA', 'fileB', 'someFile']
37 ],
38 'hidden file' => [
39 ['someFile', '.hiddenFile'],
40 ['.hiddenFile', 'someFile']
41 ],
42 'mixed capitalization' => [
43 ['alllower', 'allCAPS', 'ALLcaps', 'mIxedinanotherway', 'ALLCAPS', 'MiXeDcApItAlIzAtIoN'],
44 ['ALLCAPS', 'ALLcaps', 'allCAPS', 'alllower', 'MiXeDcApItAlIzAtIoN', 'mIxedinanotherway']
45 ],
46 'mixed capitalization reversed' => [
47 ['MiXeDcApItAlIzAtIoN', 'mIxedinanotherway', 'ALLcaps', 'allCAPS', 'ALLCAPS', 'alllower'],
48 ['ALLCAPS', 'ALLcaps', 'allCAPS', 'alllower', 'MiXeDcApItAlIzAtIoN', 'mIxedinanotherway']
49 ],
50 'recursive list with one sublevel' => [
51 ['fileA', 'fileB', 'anotherDir/someFile', 'someDir/someFile', 'anotherDir/anotherFile'],
52 ['anotherDir/anotherFile', 'anotherDir/someFile', 'someDir/someFile', 'fileA', 'fileB']
53 ],
54 'recursive list with two sub-levels' => [
55 ['file', 'someDir/someFile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/anotherDir/somefile', 'anotherDir/someFile'],
56 ['anotherDir/someFile', 'someDir/anotherDir/somefile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/someFile', 'file']
57 ],
58 'recursive list with three sub-levels' => [
59 ['someDir/someSubdir/file', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/someSubsubdir/anotherFile'],
60 ['someDir/someSubdir/someSubsubdir/anotherFile', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/file']
61 ]
62 ];
63 }
64
65 /**
66 * @dataProvider recursiveFileListSortingHelperTestDataProvider
67 * @test
68 * @param array $unsortedList
69 * @param array $expectedList
70 */
71 public function recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList)
72 {
73 $result = $unsortedList;
74 usort(
75 $result,
76 [ResourceUtility::class, 'recursiveFileListSortingHelper']
77 );
78 $this->assertSame($expectedList, $result);
79 }
80 }