[TASK] Introduce base class for PHPUnit tests
authorMarkus Klein <klein.t3@mfc-linz.at>
Fri, 21 Sep 2012 15:55:39 +0000 (17:55 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 22 Sep 2012 19:06:25 +0000 (21:06 +0200)
Resolves: #41171
Releases: 6.0

Change-Id: I7274abf41766d16eabc5f4a127a9af6ad450066e
Reviewed-on: http://review.typo3.org/14857
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Tests/Unit/BaseTestCase.php
typo3/sysext/extbase/Tests/Unit/Configuration/BackendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/SessionTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Storage/Typo3DbBackendTest.php
typo3/sysext/extbase/Tests/Unit/Utility/ExtensionUtilityTest.php

index 2e71554..870facc 100644 (file)
@@ -29,7 +29,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit;
 /**
  * Base testcase for the Extbase extension.
  */
-abstract class BaseTestCase extends \tx_phpunit_testcase {
+abstract class BaseTestCase extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
@@ -47,72 +47,5 @@ abstract class BaseTestCase extends \tx_phpunit_testcase {
                $this->objectManager = clone $objectManager;
                parent::runBare();
        }
-
-       /**
-        * Returns a mock object which allows for calling protected methods and access
-        * of protected properties.
-        *
-        * @param string $originalClassName
-        * @param array $methods
-        * @param array $arguments
-        * @param string $mockClassName
-        * @param boolean $callOriginalConstructor
-        * @param boolean $callOriginalClone
-        * @param boolean $callAutoload
-        * @return object
-        * @author Robert Lemke <robert@typo3.org>
-        * @api
-        */
-       protected function getAccessibleMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) {
-               return $this->getMock($this->buildAccessibleProxy($originalClassName), $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload);
-       }
-
-       /**
-        * Creates a proxy class of the specified class which allows
-        * for calling even protected methods and access of protected properties.
-        *
-        * @param string $className Full qualified name of the original class
-        * @return string Full qualified name of the built class
-        */
-       protected function buildAccessibleProxy($className) {
-               $accessibleClassName = uniqid('AccessibleTestProxy');
-               $class = new \ReflectionClass($className);
-               $abstractModifier = $class->isAbstract() ? 'abstract ' : '';
-               eval('
-                       ' . $abstractModifier . 'class ' . $accessibleClassName . ' extends ' . $className . ' {
-                               public function _call($methodName) {
-                                       $args = func_get_args();
-                                       return call_user_func_array(array($this, $methodName), array_slice($args, 1));
-                               }
-                               public function _callRef($methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5= NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL) {
-                                       switch (func_num_args()) {
-                                               case 0 : return $this->$methodName();
-                                               case 1 : return $this->$methodName($arg1);
-                                               case 2 : return $this->$methodName($arg1, $arg2);
-                                               case 3 : return $this->$methodName($arg1, $arg2, $arg3);
-                                               case 4 : return $this->$methodName($arg1, $arg2, $arg3, $arg4);
-                                               case 5 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5);
-                                               case 6 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
-                                               case 7 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
-                                               case 8 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
-                                               case 9 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
-                                       }
-                               }
-                               public function _set($propertyName, $value) {
-                                       $this->$propertyName = $value;
-                               }
-                               public function _setRef($propertyName, &$value) {
-                                       $this->$propertyName = $value;
-                               }
-                               public function _get($propertyName) {
-                                       return $this->$propertyName;
-                               }
-                       }
-               ');
-               return $accessibleClassName;
-       }
-
 }
-
-
 ?>
\ No newline at end of file
index 77626f9..f6a3041 100644 (file)
@@ -35,14 +35,6 @@ class BackendConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
         */
        protected $backupGlobals = TRUE;
 
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
        /**
         * @var \TYPO3\CMS\Core\Database\DatabaseConnection
         */
index f3b1242..396b00a 100644 (file)
@@ -26,7 +26,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence;
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-class SessionTest extends \tx_phpunit_testcase {
+class SessionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
index 55b3bb1..79f05c2 100644 (file)
@@ -35,14 +35,6 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         */
        protected $backupGlobals = true;
 
-       /**
-        * Excludes TYPO3_DB from backup/restore of $GLOBALS because
-        * resource types cannot be handled during serializing.
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
        /**
         * This is the data provider for the statement generation with a basic comparison
         *
index 1ee5681..2969209 100644 (file)
@@ -29,7 +29,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Utility;
  * @package Extbase
  * @subpackage extbase
  */
-class ExtensionUtilityTest extends \tx_phpunit_testcase {
+class ExtensionUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * Enable backup of global and system variables
@@ -38,14 +38,6 @@ class ExtensionUtilityTest extends \tx_phpunit_testcase {
         */
        protected $backupGlobals = TRUE;
 
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
        /**
         * A backup of the global database
         *