[TASK] Removes eval() in extbase SignalSlot Unit Tests 50/42350/3
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 7 Aug 2015 09:14:47 +0000 (11:14 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 7 Aug 2015 09:53:53 +0000 (11:53 +0200)
Resolves: #68799
Releases: master
Change-Id: I509f379841e5f4d9e01ee477699b198d17e1c9d7
Reviewed-on: http://review.typo3.org/42350
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/extbase/Tests/Unit/SignalSlot/DispatcherTest.php
typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/OnlyClassNameSpecifiedFixture.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/SlotMethodDoesNotExistFixture.php [new file with mode: 0644]

index 98cadaf..9e68d1a 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\SignalSlot;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extbase\Tests\Unit\SignalSlot\Fixtures\OnlyClassNameSpecifiedFixture;
+use TYPO3\CMS\Extbase\Tests\Unit\SignalSlot\Fixtures\SlotMethodDoesNotExistFixture;
+
 /**
  * Test case
  */
@@ -86,9 +89,8 @@ class DispatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function dispatchRetrievesSlotInstanceFromTheObjectManagerIfOnlyAClassNameWasSpecified() {
-               $slotClassName = $this->getUniqueId('Mock_');
-               eval('class ' . $slotClassName . ' { function slot($foo, $baz) { $this->arguments = array($foo, $baz); } }');
-               $mockSlot = new $slotClassName();
+               $slotClassName = OnlyClassNameSpecifiedFixture::class;
+               $mockSlot = new OnlyClassNameSpecifiedFixture();
                $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
                $mockObjectManager->expects($this->once())->method('isRegistered')->with($slotClassName)->will($this->returnValue(TRUE));
                $mockObjectManager->expects($this->once())->method('get')->with($slotClassName)->will($this->returnValue($mockSlot));
@@ -237,9 +239,8 @@ class DispatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @expectedException \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
         */
        public function dispatchThrowsAnExceptionIfTheSpecifiedSlotMethodDoesNotExist() {
-               $slotClassName = $this->getUniqueId('Mock_');
-               eval('class ' . $slotClassName . ' { function slot($foo, $baz) { $this->arguments = array($foo, $baz); } }');
-               $mockSlot = new $slotClassName();
+               $slotClassName = SlotMethodDoesNotExistFixture::class;
+               $mockSlot = new SlotMethodDoesNotExistFixture();
                $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
                $mockObjectManager->expects($this->once())->method('isRegistered')->with($slotClassName)->will($this->returnValue(TRUE));
                $mockObjectManager->expects($this->once())->method('get')->with($slotClassName)->will($this->returnValue($mockSlot));
diff --git a/typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/OnlyClassNameSpecifiedFixture.php b/typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/OnlyClassNameSpecifiedFixture.php
new file mode 100644 (file)
index 0000000..9aa8e77
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\Unit\SignalSlot\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!
+ */
+
+/**
+ * Fixture
+ */
+class OnlyClassNameSpecifiedFixture {
+
+       /**
+        * @var array
+        */
+       public $arguments;
+
+       /**
+        * @param string $foo
+        * @param string $baz
+        */
+       public function slot($foo, $baz) {
+               $this->arguments = array($foo, $baz);
+       }
+
+}
diff --git a/typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/SlotMethodDoesNotExistFixture.php b/typo3/sysext/extbase/Tests/Unit/SignalSlot/Fixtures/SlotMethodDoesNotExistFixture.php
new file mode 100644 (file)
index 0000000..7f11ec7
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\Unit\SignalSlot\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!
+ */
+
+/**
+ * Fixture
+ */
+class SlotMethodDoesNotExistFixture {
+
+       /**
+        * @var array
+        */
+       public $arguments;
+
+       /**
+        * @param string $foo
+        * @param string $baz
+        */
+       public function slot($foo, $baz) {
+               $this->arguments = array($foo, $baz);
+       }
+
+}