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