/**
  * @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);
 }
 /**
  * @test
  * @expectedException \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException
  */
 public function initiateSubRequestThrowsExceptionIfControllerIsNoWidgetController()
 {
     $controller = $this->getMock(\TYPO3\Flow\Mvc\Controller\ControllerInterface::class);
     $this->viewHelper->_set('controller', $controller);
     $this->viewHelper->_call('initiateSubRequest');
 }