2 namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Widget;
69 $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\
Fluid\Core\Widget\AbstractWidgetViewHelper::class, array(
'validateArguments',
'initialize',
'callRenderMethod',
'getWidgetConfiguration',
'getRenderingContext'));
70 $this->mockExtensionService = $this->getMock(\TYPO3\CMS\Extbase\Service\ExtensionService::class);
71 $this->viewHelper->_set(
'extensionService', $this->mockExtensionService);
72 $this->ajaxWidgetContextHolder = $this->getMock(\TYPO3\CMS\
Fluid\Core\Widget\AjaxWidgetContextHolder::class, array(), array(),
'',
false);
73 $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder);
74 $this->widgetContext = $this->getMock(\TYPO3\CMS\
Fluid\Core\Widget\WidgetContext::class);
75 $this->objectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
76 $this->objectManager->expects($this->at(0))->method(
'get')->with(\TYPO3\CMS\
Fluid\Core\Widget\WidgetContext::class)->will($this->returnValue($this->widgetContext));
77 $this->viewHelper->injectObjectManager($this->objectManager);
78 $this->request = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
79 $this->controllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array(), array(),
'',
false);
80 $this->controllerContext->expects($this->any())->method(
'getRequest')->will($this->returnValue($this->request));
81 $this->viewHelper->_set(
'controllerContext', $this->controllerContext);
97 $this->viewHelper->_set(
'ajaxWidget',
true);
98 $this->ajaxWidgetContextHolder->expects($this->once())->method(
'store')->with($this->widgetContext);
109 $mockViewHelperVariableContainer = $this->getMock(\TYPO3\CMS\
Fluid\Core\ViewHelper\ViewHelperVariableContainer::class);
110 $mockRenderingContext = $this->getMock(\TYPO3\CMS\
Fluid\Core\Rendering\RenderingContextInterface::class);
111 $mockRenderingContext->expects($this->atLeastOnce())->method(
'getViewHelperVariableContainer')->will($this->returnValue($mockViewHelperVariableContainer));
112 $this->viewHelper->setRenderingContext($mockRenderingContext);
113 $this->viewHelper->expects($this->once())->method(
'getWidgetConfiguration')->will($this->returnValue(
'Some Widget Configuration'));
114 $this->widgetContext->expects($this->once())->method(
'setWidgetConfiguration')->with(
'Some Widget Configuration');
115 $this->widgetContext->expects($this->once())->method(
'setWidgetIdentifier')->with(
'@widget_0');
116 $this->viewHelper->_set(
'controller',
new \stdClass());
117 $this->widgetContext->expects($this->once())->method(
'setControllerObjectName')->with(
'stdClass');
118 $this->viewHelper->expects($this->once())->method(
'validateArguments');
119 $this->viewHelper->expects($this->once())->method(
'initialize');
120 $this->viewHelper->expects($this->once())->method(
'callRenderMethod')->will($this->returnValue(
'renderedResult'));
121 $output = $this->viewHelper->initializeArgumentsAndRender();
122 $this->assertEquals(
'renderedResult', $output);
130 $node1 = $this->getMock(\TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\AbstractNode::class);
131 $node2 = $this->getMock(\TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\TextNode::class, array(), array(),
'',
false);
132 $node3 = $this->getMock(\TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\AbstractNode::class);
133 $rootNode = $this->getMock(\TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\RootNode::class);
134 $rootNode->expects($this->at(0))->method(
'addChildNode')->with($node1);
135 $rootNode->expects($this->at(1))->method(
'addChildNode')->with($node2);
136 $rootNode->expects($this->at(2))->method(
'addChildNode')->with($node3);
137 $this->objectManager->expects($this->once())->method(
'get')->with(\TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\RootNode::class)->will($this->returnValue($rootNode));
138 $renderingContext = $this->getMock(\TYPO3\CMS\
Fluid\Core\Rendering\RenderingContextInterface::class);
139 $this->viewHelper->_set(
'renderingContext', $renderingContext);
140 $this->widgetContext->expects($this->once())->method(
'setViewHelperChildNodes')->with($rootNode, $renderingContext);
141 $this->viewHelper->setChildNodes(array($node1, $node2, $node3));
150 $controller = $this->getMock(
'Tx_Fluid_MVC_Controller_ControllerInterface');
151 $this->viewHelper->_set(
'controller', $controller);
152 $this->viewHelper->_call(
'initiateSubRequest');
160 $controller = $this->getMock(\TYPO3\CMS\
Fluid\Core\Widget\AbstractWidgetController::class, array(), array(),
'',
false);
161 $this->viewHelper->_set(
'controller', $controller);
163 $widgetRequest = $this->getMock(\TYPO3\CMS\
Fluid\Core\Widget\WidgetRequest::class);
164 $response = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
165 $this->objectManager->expects($this->at(0))->method(
'get')->with(\TYPO3\CMS\
Fluid\Core\Widget\WidgetRequest::class)->will($this->returnValue($widgetRequest));
166 $this->objectManager->expects($this->at(1))->method(
'get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Response::class)->will($this->returnValue(
$response));
168 $widgetRequest->expects($this->once())->method(
'setWidgetContext')->with($this->widgetContext);
171 $this->controllerContext->expects($this->once())->method(
'getRequest')->will($this->returnValue($this->request));
172 $this->widgetContext->expects($this->once())->method(
'getWidgetIdentifier')->will($this->returnValue(
'widget-1'));
173 $this->request->expects($this->once())->method(
'getArguments')->will($this->returnValue(array(
178 'action' =>
'myAction'
181 $widgetRequest->expects($this->once())->method(
'setArguments')->with(array(
185 $widgetRequest->expects($this->once())->method(
'setControllerActionName')->with(
'myAction');
187 $controller->expects($this->once())->method(
'processRequest')->with($widgetRequest,
$response);
188 $output = $this->viewHelper->_call(
'initiateSubRequest');