68 $this->viewHelper = $this->
getAccessibleMock(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetViewHelper', array(
'validateArguments',
'initialize',
'callRenderMethod',
'getWidgetConfiguration',
'getRenderingContext'));
69 $this->mockExtensionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Service\\ExtensionService');
70 $this->viewHelper->_set(
'extensionService', $this->mockExtensionService);
71 $this->ajaxWidgetContextHolder = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder', array(), array(),
'', FALSE);
72 $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder);
73 $this->widgetContext = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetContext');
74 $this->objectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
75 $this->objectManager->expects($this->at(0))->method(
'get')->with(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetContext')->will($this->returnValue($this->widgetContext));
76 $this->viewHelper->injectObjectManager($this->objectManager);
77 $this->request = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
78 $this->controllerContext = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(),
'', FALSE);
79 $this->controllerContext->expects($this->any())->method(
'getRequest')->will($this->returnValue($this->request));
80 $this->viewHelper->_set(
'controllerContext', $this->controllerContext);
94 $this->viewHelper->_set(
'ajaxWidget', TRUE);
95 $this->ajaxWidgetContextHolder->expects($this->once())->method(
'store')->with($this->widgetContext);
105 $mockViewHelperVariableContainer = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
106 $mockRenderingContext = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContextInterface');
107 $mockRenderingContext->expects($this->atLeastOnce())->method(
'getViewHelperVariableContainer')->will($this->returnValue($mockViewHelperVariableContainer));
108 $this->viewHelper->setRenderingContext($mockRenderingContext);
109 $this->viewHelper->expects($this->once())->method(
'getWidgetConfiguration')->will($this->returnValue(
'Some Widget Configuration'));
110 $this->widgetContext->expects($this->once())->method(
'setWidgetConfiguration')->with(
'Some Widget Configuration');
111 $this->widgetContext->expects($this->once())->method(
'setWidgetIdentifier')->with(
'@widget_0');
112 $this->viewHelper->_set(
'controller',
new \stdClass());
113 $this->widgetContext->expects($this->once())->method(
'setControllerObjectName')->with(
'stdClass');
114 $this->viewHelper->expects($this->once())->method(
'validateArguments');
115 $this->viewHelper->expects($this->once())->method(
'initialize');
116 $this->viewHelper->expects($this->once())->method(
'callRenderMethod')->will($this->returnValue(
'renderedResult'));
117 $output = $this->viewHelper->initializeArgumentsAndRender();
118 $this->assertEquals(
'renderedResult', $output);
125 $node1 = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\AbstractNode');
126 $node2 = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', array(), array(),
'', FALSE);
127 $node3 = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\AbstractNode');
128 $rootNode = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\RootNode');
129 $rootNode->expects($this->at(0))->method(
'addChildNode')->with($node1);
130 $rootNode->expects($this->at(1))->method(
'addChildNode')->with($node2);
131 $rootNode->expects($this->at(2))->method(
'addChildNode')->with($node3);
132 $this->objectManager->expects($this->once())->method(
'get')->with(
'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\RootNode')->will($this->returnValue($rootNode));
133 $renderingContext = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContextInterface');
134 $this->viewHelper->_set(
'renderingContext', $renderingContext);
135 $this->widgetContext->expects($this->once())->method(
'setViewHelperChildNodes')->with($rootNode, $renderingContext);
136 $this->viewHelper->setChildNodes(array($node1, $node2, $node3));
144 $controller = $this->getMock(
'Tx_Fluid_MVC_Controller_ControllerInterface');
145 $this->viewHelper->_set(
'controller', $controller);
146 $this->viewHelper->_call(
'initiateSubRequest');
153 $controller = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetController', array(), array(),
'', FALSE);
154 $this->viewHelper->_set(
'controller', $controller);
156 $widgetRequest = $this->getMock(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetRequest');
157 $response = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
158 $this->objectManager->expects($this->at(0))->method(
'get')->with(
'TYPO3\\CMS\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($widgetRequest));
159 $this->objectManager->expects($this->at(1))->method(
'get')->with(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->will($this->returnValue($response));
161 $widgetRequest->expects($this->once())->method(
'setWidgetContext')->with($this->widgetContext);
164 $this->controllerContext->expects($this->once())->method(
'getRequest')->will($this->returnValue($this->request));
165 $this->widgetContext->expects($this->once())->method(
'getWidgetIdentifier')->will($this->returnValue(
'widget-1'));
166 $this->request->expects($this->once())->method(
'getArguments')->will($this->returnValue(array(
171 'action' =>
'myAction' 174 $widgetRequest->expects($this->once())->method(
'setArguments')->with(array(
178 $widgetRequest->expects($this->once())->method(
'setControllerActionName')->with(
'myAction');
180 $controller->expects($this->once())->method(
'processRequest')->with($widgetRequest, $response);
181 $output = $this->viewHelper->_call(
'initiateSubRequest');
183 $this->assertSame($response, $output);
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)