‪TYPO3CMS  10.4
ResourceUtilityTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪ResourceUtilityTest extends UnitTestCase
25 {
30  {
31  return [
32  'normal file list' => [
33  ['fileB', 'fileA', 'someFile'],
34  ['fileA', 'fileB', 'someFile']
35  ],
36  'already in correct order' => [
37  ['fileA', 'fileB', 'someFile'],
38  ['fileA', 'fileB', 'someFile']
39  ],
40  'hidden file' => [
41  ['someFile', '.hiddenFile'],
42  ['.hiddenFile', 'someFile']
43  ],
44  'mixed capitalization' => [
45  ['alllower', 'allCAPS', 'ALLcaps', 'mIxedinanotherway', 'ALLCAPS', 'MiXeDcApItAlIzAtIoN'],
46  ['ALLCAPS', 'ALLcaps', 'allCAPS', 'alllower', 'MiXeDcApItAlIzAtIoN', 'mIxedinanotherway']
47  ],
48  'mixed capitalization reversed' => [
49  ['MiXeDcApItAlIzAtIoN', 'mIxedinanotherway', 'ALLcaps', 'allCAPS', 'ALLCAPS', 'alllower'],
50  ['ALLCAPS', 'ALLcaps', 'allCAPS', 'alllower', 'MiXeDcApItAlIzAtIoN', 'mIxedinanotherway']
51  ],
52  'recursive list with one sublevel' => [
53  ['fileA', 'fileB', 'anotherDir/someFile', 'someDir/someFile', 'anotherDir/anotherFile'],
54  ['anotherDir/anotherFile', 'anotherDir/someFile', 'someDir/someFile', 'fileA', 'fileB']
55  ],
56  'recursive list with two sub-levels' => [
57  ['file', 'someDir/someFile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/anotherDir/somefile', 'anotherDir/someFile'],
58  ['anotherDir/someFile', 'someDir/anotherDir/somefile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/someFile', 'file']
59  ],
60  'recursive list with three sub-levels' => [
61  ['someDir/someSubdir/file', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/someSubsubdir/anotherFile'],
62  ['someDir/someSubdir/someSubsubdir/anotherFile', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/file']
63  ]
64  ];
65  }
66 
73  public function ‪recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList)
74  {
75  $result = $unsortedList;
76  usort(
77  $result,
78  [ResourceUtility::class, 'recursiveFileListSortingHelper']
79  );
80  self::assertSame($expectedList, $result);
81  }
82 }
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest\recursiveFileListSortingHelperCorrectlySorts
‪recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList)
Definition: ResourceUtilityTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest\recursiveFileListSortingHelperTestDataProvider
‪array recursiveFileListSortingHelperTestDataProvider()
Definition: ResourceUtilityTest.php:29
‪TYPO3\CMS\Core\Utility\ResourceUtility
Definition: ResourceUtility.php:22
‪TYPO3\CMS\Core\Tests\Unit\Utility\ResourceUtilityTest
Definition: ResourceUtilityTest.php:25