[TASK] Removes eval() in core path utility unit tests 35/40435/3
authorPierrick Caillon <pierrick.caillon@plan-net.fr>
Thu, 18 Jun 2015 10:39:56 +0000 (12:39 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 18 Jun 2015 21:14:18 +0000 (23:14 +0200)
Adds fixture for a Windows environment PathUtility and removes the
ugly usage of eval() from PathUtilityTest in unit tests.

Resolves: #67596
Related: #67468
Releases: master
Change-Id: I0f4135e6f9200c529854a28acefa01953c8bdf89
Reviewed-on: http://review.typo3.org/40435
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Tests/Unit/Utility/Fixtures/WindowsPathUtilityFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Utility/PathUtilityTest.php

diff --git a/typo3/sysext/core/Tests/Unit/Utility/Fixtures/WindowsPathUtilityFixture.php b/typo3/sysext/core/Tests/Unit/Utility/Fixtures/WindowsPathUtilityFixture.php
new file mode 100644 (file)
index 0000000..e2e76a3
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Utility\PathUtility;
+
+/**
+ * Fixture for forced windows environment
+ */
+class WindowsPathUtilityFixture extends PathUtility {
+
+       /**
+        * Is windows?
+        *
+        * @return bool
+        */
+       static public function isWindows() {
+               return TRUE;
+       }
+}
index 4187475..f50de39 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\WindowsPathUtilityFixture;
 
 /**
  * Testcase for class \TYPO3\CMS\Core\Utility\PathUtility
@@ -338,21 +339,9 @@ class PathUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @dataProvider getCanonicalPathCorrectlyCleansPathDataProvider
         */
        public function getCanonicalPathCorrectlyCleansPath($inputName, $expectedResult) {
-               $className = $this->getUniqueId('PathUtilityFixture');
-               $fixtureClassString = '
-                       namespace ' . ltrim(__NAMESPACE__, '\\') . ';
-                       class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\PathUtility {
-                               static public function isWindows() {
-                                       return TRUE;
-                               }
-                       }
-               ';
-               eval($fixtureClassString);
-               $fullyQualifiedClassName = __NAMESPACE__ . '\\' . $className;
-
                $this->assertEquals(
                        $expectedResult,
-                       $fullyQualifiedClassName::getCanonicalPath($inputName)
+                       WindowsPathUtilityFixture::getCanonicalPath($inputName)
                );
        }