[BUGFIX] Allow whitespaces in list of file extensions 37/53337/5
authorDaniel Goerz <dlg@lightwerk.com>
Tue, 27 Jun 2017 10:35:22 +0000 (12:35 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Jun 2017 12:55:51 +0000 (14:55 +0200)
This ensures that spaces can be used to format the list of file
extensions for <INCLUDE_TYPOSCRIPT>.

Resolves: #81709
Releases: master, 8.7
Change-Id: Ia0c830df52b18a3dae7bd724c4bd5ee3b845e00f
Reviewed-on: https://review.typo3.org/53337
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index 0aa26fc..ef62095 100644 (file)
@@ -2213,7 +2213,7 @@ class GeneralUtility
         }
 
         $pathPrefix = $path . '/';
-        $extensionList = ',' . $extensionList . ',';
+        $extensionList = ',' . str_replace(' ', '', $extensionList) . ',';
         $files = [];
         foreach ($rawFileList as $entry) {
             $completePathToEntry = $pathPrefix . $entry;
index 0bfcbc1..7534fa7 100644 (file)
@@ -3272,14 +3272,39 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     }
 
     /**
+     * Data provider for getFilesInDirByExtensionFindsFiles
+     *
+     * @return array
+     */
+    public function fileExtensionDataProvider()
+    {
+        return [
+            'no space' => [
+                'txt,js,css'
+            ],
+            'spaces' => [
+                'txt, js, css'
+            ],
+            'mixed' => [
+                'txt,js, css'
+            ],
+            'wild' => [
+                'txt,     js  ,         css'
+            ]
+        ];
+    }
+
+    /**
+     * @dataProvider fileExtensionDataProvider
      * @test
      */
-    public function getFilesInDirByExtensionFindsFiles()
+    public function getFilesInDirByExtensionFindsFiles($fileExtensions)
     {
         $vfsStreamUrl = $this->getFilesInDirCreateTestDirectory();
-        $files = GeneralUtility::getFilesInDir($vfsStreamUrl, 'txt,js');
+        $files = GeneralUtility::getFilesInDir($vfsStreamUrl, $fileExtensions);
         $this->assertContains('testA.txt', $files);
         $this->assertContains('test.js', $files);
+        $this->assertContains('test.css', $files);
     }
 
     /**