[TASK] Unit tests for getFileAbsFileName 83/46783/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 19 Feb 2016 16:26:31 +0000 (17:26 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 19 Feb 2016 16:34:21 +0000 (17:34 +0100)
Change-Id: If2d8c342e6632ab86a7744ac6d019fcc1f7af74c
Resolves: #73572
Related: #73516
Releases: master
Reviewed-on: https://review.typo3.org/46783
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index c8b402d..bedf321 100644 (file)
@@ -4177,6 +4177,45 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     }
 
     /**
+     * @return array
+     */
+    public function getFileAbsFileNameDateprovider()
+    {
+        return [
+            'sysext/core/ext_icon.png, true, true' => ['sysext/core/ext_icon.png', true, true, PATH_site . 'typo3/sysext/core/ext_icon.png'],
+            'fileadmin/foo.txt, true, false' => ['fileadmin/foo.txt', true, false, PATH_site . 'fileadmin/foo.txt'],
+            'sysext/core/ext_icon.png, false, true' => ['sysext/core/ext_icon.png', false, true, PATH_site . 'typo3/sysext/core/ext_icon.png'],
+            'fileadmin/foo.txt, false, false' => ['fileadmin/foo.txt', false, false, PATH_site . 'fileadmin/foo.txt'],
+            './sysext/core/ext_icon.png, true, true' => ['./sysext/core/ext_icon.png', true, true, PATH_site . 'typo3/./sysext/core/ext_icon.png'],
+            './fileadmin/foo.txt, true, false' => ['./fileadmin/foo.txt', true, false, PATH_site . './fileadmin/foo.txt'],
+            './sysext/core/ext_icon.png, false, true' => ['./sysext/core/ext_icon.png', false, true, PATH_site . 'typo3/./sysext/core/ext_icon.png'],
+            './fileadmin/foo.txt, false, false' => ['./fileadmin/foo.txt', false, false, PATH_site . './fileadmin/foo.txt'],
+            '../sysext/core/ext_icon.png, true, true' => ['../sysext/core/ext_icon.png', true, true, ''],
+            '../fileadmin/foo.txt, true, false' => ['../fileadmin/foo.txt', true, false, ''],
+            '../sysext/core/ext_icon.png, false, true' => ['../sysext/core/ext_icon.png', false, true, ''],
+            '../fileadmin/foo.txt, false, false' => ['../fileadmin/foo.txt', false, false, ''],
+            'PATH_site . sysext/core/ext_icon.png, true, true' => [PATH_site . 'sysext/core/ext_icon.png', true, true, ''],
+            'PATH_site . fileadmin/foo.txt, true, false' => [PATH_site . 'fileadmin/foo.txt', true, false, PATH_site . 'fileadmin/foo.txt'],
+            'PATH_site . typo3/sysext/core/ext_icon.png, false, true' => [PATH_site . 'typo3/sysext/core/ext_icon.png', false, true, PATH_site . 'typo3/sysext/core/ext_icon.png'],
+            'PATH_site . fileadmin/foo.txt, false, false' => [PATH_site . 'fileadmin/foo.txt', false, false, PATH_site . 'fileadmin/foo.txt'],
+        ];
+    }
+
+    /**
+     * @param string $path
+     * @param bool $onlyRelative
+     * @param bool $relToTYPO3_mainDir
+     * @param string $expected
+     * @test
+     * @dataProvider getFileAbsFileNameDateprovider
+     */
+    public function getFileAbsFileNameReturnsCorrectValues($path, $onlyRelative, $relToTYPO3_mainDir, $expected)
+    {
+        $result = GeneralUtility::getFileAbsFileName($path, $onlyRelative, $relToTYPO3_mainDir);
+        $this->assertEquals($expected, $result);
+    }
+
+    /**
      * Data provider for validPathStrDetectsInvalidCharacters.
      *
      * @return array