[BUGFIX] Fix failing tests in ActionControllerTest
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 6 Jan 2013 09:38:07 +0000 (10:38 +0100)
committerAlexander Schnitzler <typo3@alexanderschnitzler.de>
Sun, 6 Jan 2013 10:04:40 +0000 (11:04 +0100)
Introduction of signals into ActionController caused
some Unit Tests to fail. This patch injects the missing
SignalSlotDispatcher into those tests.

Fixes: #44334
Releases: 6.1
Change-Id: I44cfa71070442a83e2259d57743353dcaba0f3e7
Reviewed-on: https://review.typo3.org/17383
Reviewed-by: Alexander Schnitzler
Tested-by: Alexander Schnitzler
typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php

index 268a700..eda35f8 100644 (file)
@@ -36,7 +36,6 @@ abstract class AbstractController implements \TYPO3\CMS\Extbase\Mvc\Controller\C
 
        /**
         * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
-        * @inject
         */
        protected $signalSlotDispatcher;
 
@@ -202,6 +201,15 @@ abstract class AbstractController implements \TYPO3\CMS\Extbase\Mvc\Controller\C
        }
 
        /**
+        * Injects the signal slot dispatcher
+        *
+        * @param \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher
+        */
+       public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher) {
+               $this->signalSlotDispatcher = $signalSlotDispatcher;
+       }
+
+       /**
         * Checks if the current request type is supported by the controller.
         *
         * If your controller only supports certain request types, either
index e47ca6f..51ee805 100644 (file)
@@ -100,6 +100,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction')->will($this->returnValue('the returned string'));
                $mockController->_set('request', $mockRequest);
@@ -124,6 +126,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction');
                $mockController->_set('request', $mockRequest);
@@ -172,6 +176,8 @@ class ActionControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockArgumentMappingResults = $this->getMock('TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction', 'initializeAction'), array(), '', FALSE);
+               $mockSignalSlotDispatcher = $this->getMock('TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(), '', FALSE);
+               $mockController->injectSignalSlotDispatcher($mockSignalSlotDispatcher);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $mockController->expects($this->once())->method('fooAction')->with('Default value');
                $mockController->_set('request', $mockRequest);