[TASK] Cleanup DataMapperTest 84/55284/2
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Fri, 5 Jan 2018 14:42:01 +0000 (15:42 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 8 Jan 2018 20:02:39 +0000 (21:02 +0100)
Replace evaled classes with actual fixtures

Releases: master
Resolves: #83488
Change-Id: Id9b5e3040a8fde8cf260423dfdd1448f6675f09f
Reviewed-on: https://review.typo3.org/55284
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Reiner Teubner <reiner.teubner@me.com>
Tested-by: Reiner Teubner <reiner.teubner@me.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyChildEntity.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyEntity.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyParentEntity.php [new file with mode: 0644]

index 88477ff..9889d66 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper;
 
 /*
@@ -62,32 +63,8 @@ class DataMapperTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function thawPropertiesSetsPropertyValues()
     {
-        $className = $this->getUniqueId('Class');
-        $classNameWithNS = __NAMESPACE__ . '\\' . $className;
-        eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
-                
-                /**
-                 * @var string
-                 */
-                public $firstProperty; 
-                
-                /**
-                 * @var int
-                 */
-                public $secondProperty; 
-                
-                /**
-                 * @var float
-                 */
-                public $thirdProperty; 
-                
-                /**
-                 * @var bool
-                 */
-                public $fourthProperty;
-                }'
-        );
-        $object = new $classNameWithNS();
+        $className = Fixture\DummyEntity::class;
+        $object = new Fixture\DummyEntity();
         $row = [
             'uid' => '1234',
             'firstProperty' => 'firstValue',
@@ -105,10 +82,10 @@ class DataMapperTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $dataMap = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap::class, ['dummy'], [$className, $className]);
         $dataMap->_set('columnMaps', $columnMaps);
         $dataMaps = [
-            $classNameWithNS => $dataMap
+            $className => $dataMap
         ];
         /** @var AccessibleObjectInterface|\TYPO3\CMS\Extbase\Reflection\ClassSchema $classSchema */
-        $classSchema = new ClassSchema($classNameWithNS);
+        $classSchema = new ClassSchema($className);
         $mockReflectionService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class)
             ->setMethods(['getClassSchema'])
             ->getMock();
@@ -201,23 +178,11 @@ class DataMapperTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
 
-        $className = $this->getUniqueId('Class1');
-        $classNameWithNS = __NAMESPACE__ . '\\' . $className;
-
-        $className2 = $this->getUniqueId('Class2');
-        $className2WithNS = __NAMESPACE__ . '\\' . $className2;
-        eval('namespace ' . __NAMESPACE__ . '; class ' . $className2 . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' { }');
-        eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' { 
-            /**
-             * @var ' . $className2WithNS . '
-             */
-            public $relationProperty; 
-        }');
-        $object = new $classNameWithNS();
-        $child = new $className2WithNS();
+        $object = new Fixture\DummyParentEntity();
+        $child = new Fixture\DummyChildEntity();
 
         /** @var \TYPO3\CMS\Extbase\Reflection\ClassSchema|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $classSchema1 */
-        $classSchema1 = new ClassSchema($classNameWithNS);
+        $classSchema1 = new ClassSchema(Fixture\DummyParentEntity::class);
         $identifier = 1;
 
         $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyChildEntity.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyChildEntity.php
new file mode 100644 (file)
index 0000000..c114913
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;
+
+/*
+ * 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!
+ */
+
+/**
+ * Fixture
+ */
+class DummyChildEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+{
+}
diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyEntity.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyEntity.php
new file mode 100644 (file)
index 0000000..ccd02ff
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;
+
+/*
+ * 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!
+ */
+
+/**
+ * Fixture
+ */
+class DummyEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+{
+    /**
+     * @var string
+     */
+    public $firstProperty;
+
+    /**
+     * @var int
+     */
+    public $secondProperty;
+
+    /**
+     * @var float
+     */
+    public $thirdProperty;
+
+    /**
+     * @var bool
+     */
+    public $fourthProperty;
+}
diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyParentEntity.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/Fixture/DummyParentEntity.php
new file mode 100644 (file)
index 0000000..0c4775a
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;
+
+/*
+ * 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!
+ */
+
+/**
+ * Fixture
+ */
+class DummyParentEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+{
+    /**
+     * @var \TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture\DummyChildEntity
+     */
+    public $relationProperty;
+}