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