/**
  */
 public function setUp()
 {
     $this->serverBackup = $_SERVER;
     $this->getBackup = $_GET;
     $this->postBackup = $_POST;
     $this->widgetRequestBuilder = $this->getAccessibleMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequestBuilder', array('setArgumentsFromRawRequestData'));
     $this->mockWidgetRequest = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $this->mockObjectManager = $this->getMock('TYPO3\\Fluid\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->once())->method('create')->with('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
     $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
     $this->mockWidgetContext = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetContext');
     $this->mockAjaxWidgetContextHolder = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder');
     $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
     $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
 }
Beispiel #2
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getAccessibleMock('TYPO3\\Fluid\\View\\StandaloneView', array('dummy'), array(), '', FALSE);
     $this->mockTemplateParser = $this->getMock('TYPO3\\Fluid\\Core\\Parser\\TemplateParser');
     $this->mockParsedTemplate = $this->getMock('TYPO3\\Fluid\\Core\\Parser\\ParsedTemplateInterface');
     $this->mockTemplateParser->expects($this->any())->method('parse')->will($this->returnValue($this->mockParsedTemplate));
     $this->mockConfigurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $this->mockObjectManager = $this->getMock('TYPO3\\Fluid\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockObjectManager->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockRequest = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $this->mockUriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $this->mockFlashMessages = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\FlashMessages');
     $this->mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $this->mockControllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->mockViewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->mockRenderingContext = $this->getMock('TYPO3\\Fluid\\Core\\Rendering\\RenderingContext');
     $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
     $this->view->injectTemplateParser($this->mockTemplateParser);
     $this->view->injectObjectManager($this->mockObjectManager);
     $this->view->setRenderingContext($this->mockRenderingContext);
     $this->mockTemplateCompiler = $this->getMock('TYPO3\\Fluid\\Core\\Compiler\\TemplateCompiler');
     $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\Fluid\\Object\\ObjectManagerInterface', $this->mockObjectManager);
     \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $this->mockContentObject);
 }
 /**
  * @test
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->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
     // and the action name is exctracted from the namespace.
     $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1'));
     $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array('k1' => 'k2', 'widget-1' => array('arg1' => 'val1', 'arg2' => 'val2', 'action' => 'myAction'))));
     $widgetRequest->expects($this->once())->method('setArguments')->with(array('arg1' => 'val1', 'arg2' => 'val2'));
     $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction');
     // Controller is called
     $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response);
     $output = $this->viewHelper->_call('initiateSubRequest');
     // SubResponse is returned
     $this->assertSame($response, $output);
 }