[TASK] Removes eval() in abstract backend unit tests 88/40288/5
authorAlexander Krist <mail@alex-krist.de>
Tue, 16 Jun 2015 10:57:34 +0000 (12:57 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 16 Jun 2015 16:57:42 +0000 (18:57 +0200)
Adds a new AccessibleProxy for AbstractBackend and removes the ugly
usage of eval() from AbstractBackendTest in unit tests.

Change-Id: I3c471219fe37ecf8a51cb02b60c75130fbb4ad25
Resolves: #67489
Related: #67468
Releases: master
Reviewed-on: http://review.typo3.org/40288
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Tests/Unit/Cache/Backend/AbstractBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/Fixtures/ConcreteBackendFixture.php [new file with mode: 0644]

index 3e1b032..8615870 100644 (file)
@@ -14,52 +14,22 @@ namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Tests\Unit\Cache\Backend\Fixtures\ConcreteBackendFixture;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
+
 /**
- * Testcase for the abstract cache backend
- *
- * This file is a backport from FLOW3
+ * Test case
  *
  * @author Ingo Renner <ingo@typo3.org>
  */
-class AbstractBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
-        */
-       protected $backend;
-
-       /**
-        * @return void
-        */
-       protected function setUp() {
-               $className = $this->getUniqueId('ConcreteBackend_');
-               eval('
-                       class ' . $className . ' extends TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend {
-                               public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {}
-                               public function get($entryIdentifier) {}
-                               public function has($entryIdentifier) {}
-                               public function remove($entryIdentifier) {}
-                               public function flush() {}
-                               public function flushByTag($tag) {}
-                               public function findIdentifiersByTag($tag) {}
-                               public function collectGarbage() {}
-                               public function setSomeOption($value) {
-                                       $this->someOption = $value;
-                               }
-                               public function getSomeOption() {
-                                       return $this->someOption;
-                               }
-                       }
-               ');
-               $this->backend = new $className('Testing');
-       }
+class AbstractBackendTest extends UnitTestCase {
 
        /**
         * @test
         */
        public function theConstructorCallsSetterMethodsForAllSpecifiedOptions() {
-               $className = get_class($this->backend);
-               $backend = new $className('Testing', array('someOption' => 'someValue'));
+               // The fixture class implements methods setSomeOption() and getSomeOption()
+               $backend = new ConcreteBackendFixture('Testing', array('someOption' => 'someValue'));
                $this->assertSame('someValue', $backend->getSomeOption());
        }
 
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/Fixtures/ConcreteBackendFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/Fixtures/ConcreteBackendFixture.php
new file mode 100644 (file)
index 0000000..ebf73cc
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend\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\Cache\Backend\AbstractBackend;
+
+/**
+ * Fixture implementing one set option method.
+ */
+class ConcreteBackendFixture extends AbstractBackend {
+       protected $someOption;
+
+       public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {
+       }
+
+       public function get($entryIdentifier) {
+       }
+
+       public function has($entryIdentifier) {
+       }
+
+       public function remove($entryIdentifier) {
+       }
+
+       public function flush() {
+       }
+
+       public function flushByTag($tag) {
+       }
+
+       public function findIdentifiersByTag($tag) {
+       }
+
+       public function collectGarbage() {
+       }
+
+       public function setSomeOption($value) {
+               $this->someOption = $value;
+       }
+
+       public function getSomeOption() {
+               return $this->someOption;
+       }
+}