[TASK] add mtime sort test for getFilesInDir() 36/27536/3
authorMichiel Roos <michiel@maxserv.nl>
Tue, 11 Feb 2014 08:30:07 +0000 (09:30 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 11 Feb 2014 22:37:56 +0000 (23:37 +0100)
Add a test to check for mtime sorting capability of getFilesInDir().

Change-Id: I73082bcfd1f8d46b77a228b1ea7dabc1602d9d0a
Resolves: #55864
Releases: 6.2
Reviewed-on: https://review.typo3.org/27536
Reviewed-by: Oliver Klee
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index f453d4b..212da7d 100644 (file)
@@ -3425,6 +3425,24 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
+       public function getFilesInDirCanOrderByMtime() {
+               $files = array();
+               $iterator = new \DirectoryIterator(__DIR__);
+               foreach ($iterator as $fileinfo) {
+                       if ($fileinfo->isFile()) {
+                               $files[$fileinfo->getFilename()] = $fileinfo->getMTime();
+                       }
+               }
+               asort($files);
+               $this->assertSame(
+                       array_values(Utility\GeneralUtility::getFilesInDir(__DIR__, '', FALSE, 'mtime')),
+                       array_keys($files)
+               );
+       }
+
+       /**
+        * @test
+        */
        public function getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey() {
                $vfsStreamUrl = $this->getFilesInDirCreateTestDirectory();
                $this->assertArrayHasKey(