[BUGFIX] Tame PackageStates.php in functional tests 08/27108/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 28 Jan 2014 22:39:06 +0000 (23:39 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 29 Jan 2014 18:41:18 +0000 (19:41 +0100)
Functional test bootstrap creates a full new instance
within typo3temp together with an own database. Goal is
a controlled environment without dependencies to the
parent instance.

The patch introduces separation of PackageStates.php. The file
is now compiled based on a static list of active core extensions
and optional additional extensions for specific functional tests.

Change-Id: I39e37a16b5cef5b6b1dab2ce3c4e8efc42cecbe7
Resolves: #55409
Releases: 6.2
Reviewed-on: https://review.typo3.org/27108
Reviewed-by: Thomas Maroschik
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Tests/FunctionalTestCase.php
typo3/sysext/core/Tests/FunctionalTestCaseBootstrapUtility.php

index 28cc510..20ee372 100644 (file)
@@ -68,10 +68,9 @@ abstract class FunctionalTestCase extends BaseTestCase {
         * be loaded for every test of a test case and it is not possible to change
         * the list of loaded extensions between single tests of a test case.
         *
-        * Required core extensions like core, cms, extbase and so on are loaded
-        * automatically, so there is no need to add them here. See constant
-        * REQUIRED_EXTENSIONS for a list of automatically loaded extensions.
+        * A default list of core extensions is always loaded.
         *
+        * @see FunctionalTestCaseUtility $defaultActivatedCoreExtensions
         * @var array
         */
        protected $coreExtensionsToLoad = array();
index 04ca7b8..bb99cd6 100644 (file)
@@ -50,6 +50,25 @@ class FunctionalTestCaseBootstrapUtility {
        protected $originalDatabaseName;
 
        /**
+        * @var array These extensions are always loaded
+        */
+       protected $defaultActivatedCoreExtensions = array(
+               'core',
+               'backend',
+               'frontend',
+               'cms',
+               'lang',
+               'sv',
+               'extensionmanager',
+               'recordlist',
+               'extbase',
+               'fluid',
+               'cshmanual',
+               'install',
+               'saltedpasswords'
+       );
+
+       /**
         * Set up creates a test instance and database.
         *
         * @param string $testCaseClassName Name of test case class
@@ -246,29 +265,54 @@ class FunctionalTestCaseBootstrapUtility {
        }
 
        /**
+        * Compile typo3conf/PackageStates.php containing default packages like core,
+        * a functional test specific list of additional core extensions, and a list of
+        * test extensions.
+        *
         * @param array $coreExtensionsToLoad Additional core extensions to load
         * @param array $testExtensionPaths Paths to extensions relative to document root
         * @throws Exception
         * @TODO Figure out what the intention of the upper arguments is
         */
        protected function setUpPackageStates(array $coreExtensionsToLoad, array $testExtensionPaths) {
-               $packageStates = require ORIGINAL_ROOT . 'typo3conf/PackageStates.php';
-               $packageStates['packages']['phpunit']['packagePath'] = '../../' . $packageStates['packages']['phpunit']['packagePath'];
+               $packageStates = array(
+                       'packages' => array(),
+                       'version' => 4,
+               );
+
+               // Register default list of extensions and set active
+               foreach ($this->defaultActivatedCoreExtensions as $extensionName) {
+                       $packageStates['packages'][$extensionName] = array(
+                               'state' => 'active',
+                               'packagePath' => 'typo3/sysext/' . $extensionName . '/',
+                               'classesPath' => 'Classes/',
+                       );
+               }
 
-               // Activate core extensions if currently inactive
+               // Register additional core extensions and set active
                foreach ($coreExtensionsToLoad as $extensionName) {
-                       if (!empty($packageStates['packages'][$extensionName]['state']) && $packageStates['packages'][$extensionName]['state'] !== 'active') {
-                               $packageStates['packages'][$extensionName]['state'] = 'active';
+                       if (isset($packageSates['packages'][$extensionName])) {
+                               throw new Exception(
+                                       $extensionName . ' is already registered as default core extension to load, no need to load it explicitly',
+                                       1390913893
+                               );
                        }
+                       $packageStates['packages'][$extensionName] = array(
+                               'state' => 'active',
+                               'packagePath' => 'typo3/sysext/' . $extensionName . '/',
+                               'classesPath' => 'Classes/',
+                       );
                }
 
-               // Clean and activate test extensions that have been symlinked before
+               // Activate test extensions that have been symlinked before
                foreach ($testExtensionPaths as $extensionPath) {
-                       $extensionName = basename($extensionPath);
-                       if (!empty($packageStates['packages'][$extensionName])) {
-                               unset($packageStates['packages'][$extensionName]);
+                       if (isset($packageSates['packages'][$extensionName])) {
+                               throw new Exception(
+                                       $extensionName . ' is already registered as extension to load, no need to load it explicitly',
+                                       1390913894
+                               );
                        }
-
+                       $extensionName = basename($extensionPath);
                        $packageStates['packages'][$extensionName] = array(
                                'state' => 'active',
                                'packagePath' => 'typo3conf/ext/' . $extensionName . '/',