[BUGFIX] Resolve incomplete mocking for sysext:fluid 98/28198/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 9 Mar 2014 15:43:26 +0000 (16:43 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 9 Mar 2014 15:55:14 +0000 (16:55 +0100)
Some Tests in sysext:backend rely on an existing BackendUserAuth object.
In order to decouple the tests from the TYPO3 Environment,
those are mocked now.

Change-Id: Ibfd9de2f5a7673eecca61c35e59852017edd2f0d
Resolves: #56688
Relates: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28198
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/AjaxWidgetContextHolderTest.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestBuilderTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FlashMessagesViewHelperTest.php

index 8a04baa..9a742b4 100644 (file)
@@ -67,7 +67,7 @@ class AbstractWidgetViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTes
                $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetViewHelper', array('validateArguments', 'initialize', 'callRenderMethod', 'getWidgetConfiguration', 'getRenderingContext'));
                $this->mockExtensionService = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\ExtensionService');
                $this->viewHelper->_set('extensionService', $this->mockExtensionService);
-               $this->ajaxWidgetContextHolder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder');
+               $this->ajaxWidgetContextHolder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder', array(), array(), '', FALSE);
                $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder);
                $this->widgetContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetContext');
                $this->objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
index 764d513..1e6e804 100644 (file)
@@ -27,10 +27,11 @@ class AjaxWidgetContextHolderTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
 
        /**
         * @test
-        * @expectedException TYPO3\CMS\Fluid\Core\Widget\Exception\WidgetContextNotFoundException
+        * @expectedException \TYPO3\CMS\Fluid\Core\Widget\Exception\WidgetContextNotFoundException
         */
        public function getThrowsExceptionIfWidgetContextIsNotFound() {
-               $ajaxWidgetContextHolder = new \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder();
+               /** @var \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder */
+               $ajaxWidgetContextHolder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder', array('dummy'), array(), '', FALSE);
                $ajaxWidgetContextHolder->get(42);
        }
 }
index 1058a34..73e2aa5 100644 (file)
@@ -57,7 +57,7 @@ class WidgetRequestBuilderTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCas
                $this->mockObjectManager->expects($this->once())->method('get')->with('TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
                $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
                $this->mockWidgetContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetContext');
-               $this->mockAjaxWidgetContextHolder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder');
+               $this->mockAjaxWidgetContextHolder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder', array(), array(), '', FALSE);
                $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
                $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
        }
index ad59c2d..b092e35 100644 (file)
@@ -32,8 +32,12 @@ class FlashMessagesViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelper
         * @return void
         */
        public function setUp() {
+               /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue|\PHPUnit_Framework_MockObject_MockObject $mockFlashMessagingQueue */
+               $mockFlashMessagingQueue = $this->getMock('TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue', array('getAllMessagesAndFlush'), array('foo'));
+               $mockFlashMessagingQueue->expects($this->once())->method('getAllMessagesAndFlush')->will($this->returnValue(array()));
+
                $mockControllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
-               $mockControllerContext->expects($this->any())->method('getFlashMessageQueue')->will($this->returnValue(new \TYPO3\CMS\Core\Messaging\FlashMessageQueue('foo')));
+               $mockControllerContext->expects($this->any())->method('getFlashMessageQueue')->will($this->returnValue($mockFlashMessagingQueue));
 
                $this->mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder');
                $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\FlashMessagesViewHelper', array('dummy'));