[BUGFIX] LocalDriver: Recursive file listing is broken
[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 * Copyright notice
6 *
7 * (c) 2013 Andreas Wolf <andreas.wolf@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Core\Utility\ResourceUtility;
31
32 /**
33 * Testcase for class \TYPO3\CMS\Core\Utility\ResourceUtility
34 */
35 class ResourceUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
36
37 public function recursiveFileListSortingHelperTestDataProvider() {
38 return array(
39 'normal file list' => array(
40 array('fileB', 'fileA', 'someFile'),
41 array('fileA', 'fileB', 'someFile')
42 ),
43 'already in correct order' => array(
44 array('fileA', 'fileB', 'someFile'),
45 array('fileA', 'fileB', 'someFile')
46 ),
47 'hidden file' => array(
48 array('someFile', '.hiddenFile'),
49 array('.hiddenFile', 'someFile')
50 ),
51 'mixed capitalization' => array(
52 array('alllower', 'allCAPS', 'ALLcaps', 'mIxedinanotherway', 'ALLCAPS', 'MiXeDcApItAlIzAtIoN'),
53 array('ALLCAPS', 'ALLcaps', 'allCAPS', 'alllower', 'MiXeDcApItAlIzAtIoN', 'mIxedinanotherway')
54 ),
55 'recursive list with one sublevel' => array(
56 array('fileA', 'fileB', 'anotherDir/someFile', 'someDir/someFile', 'anotherDir/anotherFile'),
57 array('anotherDir/anotherFile', 'anotherDir/someFile', 'someDir/someFile', 'fileA', 'fileB')
58 ),
59 'recursive list with two sub-levels' => array(
60 array('file', 'someDir/someFile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/anotherDir/somefile', 'anotherDir/someFile'),
61 array('anotherDir/someFile', 'someDir/anotherDir/somefile', 'someDir/subdir/file', 'someDir/subdir/somefile', 'someDir/someFile', 'file')
62 ),
63 'recursive list with three sub-levels' => array(
64 array('someDir/someSubdir/file', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/someSubsubdir/anotherFile'),
65 array('someDir/someSubdir/someSubsubdir/anotherFile', 'someDir/someSubdir/someSubsubdir/someFile', 'someDir/someSubdir/file')
66 )
67 );
68 }
69
70 /**
71 * @dataProvider recursiveFileListSortingHelperTestDataProvider
72 * @test
73 */
74 public function recursiveFileListSortingHelperCorrectlySorts($unsortedList, $expectedList) {
75 $result = $unsortedList;
76 usort(
77 $result,
78 array('\\TYPO3\\CMS\\Core\\Utility\\ResourceUtility', 'recursiveFileListSortingHelper')
79 );
80
81 $this->assertEquals($expectedList, $result);
82 }
83 }
84
85 ?>