[TASK] Tests: Reduce unit test bootstrap 49/28449/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 16 Mar 2014 17:12:44 +0000 (18:12 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 16 Mar 2014 17:27:31 +0000 (18:27 +0100)
The patch further reduces the unit test bootstrap: ext_localconf
of extensions is not loaded anymore and the cache framework is
no longer initialized. A test with incommplete mocking in this area
is fixed along the way.
Furthermore the core exception handling is no longer initialized,
so it does not depend on configuration options. A warning
triggered by a unit test will now reliable let the test fail.

Change-Id: I659441482a19eb6b434d520ecded6df8f5086820
Resolves: #51436
Related: #56967
Releases: 6.2
Reviewed-on: https://review.typo3.org/28449
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Build/UnitTestsBootstrap.php
typo3/sysext/fluid/Tests/Unit/View/StandaloneViewTest.php

index 541a153..71383c8 100644 (file)
@@ -98,7 +98,7 @@ $_SERVER['SCRIPT_NAME'] = PATH_thisScript;
 require PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
        ->baseSetup()
-       ->loadConfigurationAndInitialize(TRUE)
-       // TODO: Maybe load only core extensions here? Also check if we need to change the bootstrap since we have package management now
-       ->loadTypo3LoadedExtAndExtLocalconf(FALSE)
-       ->applyAdditionalConfigurationSettings();
+       ->loadConfigurationAndInitialize(TRUE);
+
+// 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
index ac8c50b..89a1184 100644 (file)
@@ -127,6 +127,11 @@ class StandaloneViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
                \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $this->mockObjectManager);
                \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $this->mockContentObject);
+
+               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array(), array(), '', FALSE);
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
+               $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
        }
 
        /**