‪TYPO3CMS  9.5
ResourceUtilityTest.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 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪ResourceUtilityTest extends UnitTestCase
24 {
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 
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 }
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest\recursiveFileListSortingHelperCorrectlySorts
‪recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList)
Definition: ResourceUtilityTest.php:72
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest\recursiveFileListSortingHelperTestDataProvider
‪array recursiveFileListSortingHelperTestDataProvider()
Definition: ResourceUtilityTest.php:28
‪TYPO3\CMS\Core\Utility\ResourceUtility
Definition: ResourceUtility.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest
Definition: ResourceUtilityTest.php:24