TYPO3 CMS  TYPO3_7-6
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 
23 {
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 
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 }
recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList)