[BUGFIX] Do not load LocalConfiguration in unit test bootstrap 91/28491/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 18 Mar 2014 12:28:36 +0000 (13:28 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Sat, 22 Mar 2014 20:16:14 +0000 (21:16 +0100)
The patch removes loadConfigurationAndInitialize() from unit test
bootstrap and substitutes it with some more fine grained bootstrap
calls. In effect, the instance specific LocalConfiguration.php is
no longer loaded and removes another depencency from unit tests
to the instance.

Change-Id: Ia6591fe8d40d530558a514832c8d649c46b4ccc9
Resolves: #57035
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28491
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Build/UnitTestsBootstrap.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/extbase/Tests/Unit/Security/Cryptography/HashServiceTest.php

index 71383c8..ef74bd6 100644 (file)
@@ -91,14 +91,22 @@ unset($webRoot);
 define('PATH_thisScript', PATH_site . 'typo3/cli_dispatch.phpsh');
 $_SERVER['SCRIPT_NAME'] = PATH_thisScript;
 
-/**
- * Basic bootstrap
- * Can be simplified/ stripped down once the according tests are properly mocked
- */
+putenv('TYPO3_CONTEXT=Testing');
+
 require PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
+
 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
        ->baseSetup()
-       ->loadConfigurationAndInitialize(TRUE);
+       ->initializeClassLoader();
+
+$configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
+$GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();
+
+\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
+       ->disableCoreAndClassesCache()
+       ->initializeCachingFramework()
+       ->initializeClassLoaderCaches()
+       ->initializePackageManagement('TYPO3\\CMS\\Core\\Package\\PackageManager');
 
-// Load ext_localconf of phpunit. It takes care of registering phpunit classes and dependencies like vfsStream
-require PATH_site . '/typo3conf/ext/phpunit/ext_localconf.php';
\ No newline at end of file
+require PATH_site . 'typo3conf/ext/phpunit/Composer/vendor/autoload.php';
+require PATH_site . 'typo3conf/ext/phpunit/Migrations/vfsStream.php';
index 1845073..3938098 100644 (file)
@@ -255,8 +255,9 @@ class Bootstrap {
         * Initializes the Class Loader
         *
         * @return Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
-       protected function initializeClassLoader() {
+       public function initializeClassLoader() {
                $classLoader = new ClassLoader($this->applicationContext);
                $this->setEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader', $classLoader);
                $classLoader->setRuntimeClassLoadingInformationFromAutoloadRegistry((array) include __DIR__ . '/../../ext_autoload.php');
@@ -292,8 +293,9 @@ class Bootstrap {
         * Initialize class loader cache.
         *
         * @return Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
-       protected function initializeClassLoaderCaches() {
+       public function initializeClassLoaderCaches() {
                /** @var $classLoader ClassLoader */
                $classLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
                $classLoader->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core'));
@@ -307,8 +309,9 @@ class Bootstrap {
         *
         * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
         * @return Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
-       protected function initializePackageManagement($packageManagerClassName) {
+       public function initializePackageManagement($packageManagerClassName) {
                /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
                $packageManager = new $packageManagerClassName();
                $this->setEarlyInstance('TYPO3\\Flow\\Package\\PackageManager', $packageManager);
@@ -467,8 +470,9 @@ class Bootstrap {
         * Initialize caching framework
         *
         * @return Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
-       protected function initializeCachingFramework() {
+       public function initializeCachingFramework() {
                $this->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
                // @deprecated since 6.2 will be removed in two versions
                $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
index 05bc41f..74e01d1 100644 (file)
@@ -764,6 +764,7 @@ return array(
                'hidePagesIfNotTranslatedByDefault' => FALSE,           // Boolean: If TRUE, pages that has no translation will be hidden by default. Basically this will inverse the effect of the page localization setting "Hide page if no translation for current language exists" to "Show page even if no translation exists"
                'eID_include' => array(),               // Array of key/value pairs where key is "tx_[ext]_[optional suffix]" and value is relative filename of class to include. Key is used as "?eID=" for index_ts.php to include the code file which renders the page from that point. (Useful for functionality that requires a low initialization footprint, eg. frontend ajax applications)
                'disableNoCacheParameter' => FALSE,             // Boolean: If set, the no_cache request parameter will become ineffective. This is currently still an experimental feature and will require a website only with plugins that don't use this parameter. However, using "&amp;no_cache=1" should be avoided anyway because there are better ways to disable caching for a certain part of the website (see COA_INT/USER_INT documentation in TSref).
+               'cacheHash' => array(),         // Array: Processed values of the cHash* parameters, handled by core bootstrap internally
                'cHashExcludedParameters' => 'L',               // String: The the given parameters will be ignored in the cHash calculation. Example: L,tx_search_pi1[query]
                'cHashOnlyForParameters' => '',         // String: Only the given parameters will be evaluated in the cHash calculation. Example: tx_news_pi1[uid]
                'cHashRequiredParameters' => '',                // Optional: Configure Parameters that require a cHash. If no cHash is given but one of the parameters are set, then TYPO3 triggers the configured cHash Error behaviour
index 1996332..c92ff30 100644 (file)
@@ -4141,6 +4141,7 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        ///////////////////////////////////////////////////
        // Tests concerning callUserFunction
        ///////////////////////////////////////////////////
+
        /**
         * @test
         * @dataProvider callUserFunctionInvalidParameterDataprovider
@@ -4149,7 +4150,7 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $inputData = array('foo' => 'bar');
                // omit the debug() output
                ob_start();
-               $result = Utility\GeneralUtility::callUserFunction($functionName, $inputData, $this, 'user_');
+               $result = Utility\GeneralUtility::callUserFunction($functionName, $inputData, $this, 'user_', 1);
                ob_end_clean();
                $this->assertFalse($result);
        }
index daa51a6..281d83a 100644 (file)
@@ -29,10 +29,14 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Security\Cryptography;
  */
 class HashServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
+       /**
+        * @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
+        */
        protected $hashService;
 
        public function setUp() {
                $this->hashService = new \TYPO3\CMS\Extbase\Security\Cryptography\HashService();
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'Testing';
        }
 
        /**