diff --git a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php index 4b3d86125322..715232194494 100644 --- a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php +++ b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php @@ -218,7 +218,7 @@ private function passArgumentsToSubRequest(\TYPO3\CMS\Fluid\Core\Widget\WidgetRe private function initializeWidgetIdentifier() { $widgetCounter = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper::class, 'nextWidgetNumber', 0); - $widgetIdentifier = '@widget_' . ($this->arguments['customWidgetId'] !== null ? $this->arguments['customWidgetId'] . '_' : '') . $widgetCounter; + $widgetIdentifier = '@widget_' . ((isset($this->arguments['customWidgetId']) && $this->arguments['customWidgetId'] !== null) ? $this->arguments['customWidgetId'] . '_' : '') . $widgetCounter; $this->viewHelperVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper::class, 'nextWidgetNumber', $widgetCounter + 1); $this->widgetContext->setWidgetIdentifier($widgetIdentifier); } diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php index 7fe545f7021f..9d4d4326c8dd 100644 --- a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php @@ -1,4 +1,5 @@ viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper::class, ['validateArguments', 'initialize', 'callRenderMethod', 'getWidgetConfiguration', 'getRenderingContext']); - $this->mockExtensionService = $this->createMock(\TYPO3\CMS\Extbase\Service\ExtensionService::class); + $this->viewHelper = $this->getAccessibleMock(AbstractWidgetViewHelper::class, ['validateArguments', 'initialize', 'callRenderMethod', 'getWidgetConfiguration', 'getRenderingContext']); + $this->mockExtensionService = $this->createMock(ExtensionService::class); $this->viewHelper->_set('extensionService', $this->mockExtensionService); - $this->ajaxWidgetContextHolder = $this->createMock(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder::class); + $this->ajaxWidgetContextHolder = $this->createMock(AjaxWidgetContextHolder::class); $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder); - $this->widgetContext = $this->createMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext::class); - $this->objectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class); - $this->objectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext::class)->will($this->returnValue($this->widgetContext)); + $this->widgetContext = $this->createMock(WidgetContext::class); + $this->objectManager = $this->createMock(ObjectManagerInterface::class); + $this->objectManager->expects($this->at(0))->method('get')->with(WidgetContext::class)->will($this->returnValue($this->widgetContext)); $this->viewHelper->injectObjectManager($this->objectManager); - $this->request = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class); - $this->controllerContext = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class); + $this->request = $this->createMock(Request::class); + $this->controllerContext = $this->createMock(ControllerContext::class); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); - $this->renderingContext = $this->getMockBuilder(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class) + $this->renderingContext = $this->getMockBuilder(RenderingContextFixture::class) ->setMethods(['getControllerContext']) ->getMock(); $this->renderingContext->expects($this->any())->method('getControllerContext')->willReturn($this->controllerContext); @@ -113,7 +129,7 @@ public function callViewHelper() { $mockViewHelperVariableContainer = $this->createMock(ViewHelperVariableContainer::class); $mockViewHelperVariableContainer->expects($this->any())->method('get')->willReturnArgument(2); - $mockRenderingContext = $this->createMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class); + $mockRenderingContext = $this->createMock(RenderingContextFixture::class); $mockRenderingContext->expects($this->atLeastOnce())->method('getViewHelperVariableContainer')->will($this->returnValue($mockViewHelperVariableContainer)); $mockRenderingContext->expects($this->any())->method('getControllerContext')->willReturn($this->controllerContext); $this->viewHelper->setRenderingContext($mockRenderingContext); @@ -135,15 +151,15 @@ public function callViewHelper() */ public function setChildNodesAddsChildNodesToWidgetContext() { - $node1 = $this->createMock(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode::class); - $node2 = $this->createMock(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode::class); - $node3 = $this->createMock(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode::class); - $rootNode = $this->createMock(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode::class); + $node1 = $this->createMock(AbstractNode::class); + $node2 = $this->createMock(TextNode::class); + $node3 = $this->createMock(AbstractNode::class); + $rootNode = $this->createMock(RootNode::class); $rootNode->expects($this->at(0))->method('addChildNode')->with($node1); $rootNode->expects($this->at(1))->method('addChildNode')->with($node2); $rootNode->expects($this->at(2))->method('addChildNode')->with($node3); - $this->objectManager->expects($this->once())->method('get')->with(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode::class)->will($this->returnValue($rootNode)); - $renderingContext = $this->createMock(\TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface::class); + $this->objectManager->expects($this->once())->method('get')->with(RootNode::class)->will($this->returnValue($rootNode)); + $renderingContext = $this->createMock(RenderingContextInterface::class); $this->viewHelper->_set('renderingContext', $renderingContext); $this->widgetContext->expects($this->once())->method('setViewHelperChildNodes')->with($rootNode, $renderingContext); $this->viewHelper->setChildNodes([$node1, $node2, $node3]); @@ -168,13 +184,13 @@ public function initiateSubRequestThrowsExceptionIfControllerIsNoWidgetControlle */ public function initiateSubRequestBuildsRequestProperly() { - $controller = $this->createMock(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController::class); + $controller = $this->createMock(AbstractWidgetController::class); $this->viewHelper->_set('controller', $controller); // Initial Setup - $widgetRequest = $this->createMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class); - $response = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class); - $this->objectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class)->will($this->returnValue($widgetRequest)); - $this->objectManager->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Response::class)->will($this->returnValue($response)); + $widgetRequest = $this->createMock(WidgetRequest::class); + $response = $this->createMock(Response::class); + $this->objectManager->expects($this->at(0))->method('get')->with(WidgetRequest::class)->will($this->returnValue($widgetRequest)); + $this->objectManager->expects($this->at(1))->method('get')->with(Response::class)->will($this->returnValue($response)); // Widget Context is set $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext); // The namespaced arguments are passed to the sub-request