[BUGFIX] Reset makeInstance singletons correctly
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Sep 2012 14:01:09 +0000 (16:01 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Sep 2012 14:06:51 +0000 (16:06 +0200)
StandaloneViewTest() uses GeneralUtility::purgeInstances() but does not
reset the singletons to the previous state which has side effects on
tests executed afterwards. The patch takes care of correct
reconstitution.

Change-Id: I1332fe772741240b53a10a806a7e89f630289006
Resolves: #40794
Related: #40780
Releases: 6.0
Reviewed-on: http://review.typo3.org/14498
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/fluid/Tests/Unit/View/StandaloneViewTest.php

index 5c2f14d..7139a67 100644 (file)
@@ -26,6 +26,11 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\View;
 class StandaloneViewTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var array A backup of registered singleton instances
+        */
+       protected $singletonInstances = array();
+
+       /**
         * @var \TYPO3\CMS\Fluid\View\StandaloneView
         */
        protected $view;
@@ -119,6 +124,7 @@ class StandaloneViewTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $this->view->setRenderingContext($this->mockRenderingContext);
                $this->mockTemplateCompiler = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler');
                $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
+               $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
                \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);
        }
@@ -127,7 +133,7 @@ class StandaloneViewTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @return void
         */
        public function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
        }
 
        /**