/**
  * @return void
  */
 protected function injectDependencies()
 {
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
     $this->requestBuilder->injectConfigurationManager($this->mockConfigurationManager);
     $this->mockObjectManager->expects($this->any())->method('create')->with('Tx_Extbase_MVC_Web_Request')->will($this->returnValue($this->mockRequest));
     $this->requestBuilder->injectObjectManager($this->mockObjectManager);
 }
Example #2
0
 /**
  * @test
  */
 public function executeReturnsQueryResultInstanceAndInjectsItself()
 {
     $queryResult = $this->getMock('Tx_Extbase_Persistence_QueryResult', array(), array(), '', FALSE);
     $this->objectManager->expects($this->once())->method('create')->with('Tx_Extbase_Persistence_QueryResultInterface', $this->query)->will($this->returnValue($queryResult));
     $actualResult = $this->query->execute();
     $this->assertSame($queryResult, $actualResult);
 }
 /**
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function setUp()
 {
     $this->serverBackup = $_SERVER;
     $this->getBackup = $_GET;
     $this->postBackup = $_POST;
     $this->widgetRequestBuilder = $this->getAccessibleMock('Tx_Fluid_Core_Widget_WidgetRequestBuilder', array('setArgumentsFromRawRequestData'));
     $this->mockWidgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
     $this->mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
     $this->mockObjectManager->expects($this->once())->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
     $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
     $this->mockWidgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
     $this->mockAjaxWidgetContextHolder = $this->getMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
     $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
     $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function multipleEvaluateCallsShareTheSameViewHelperInstance()
 {
     $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('render', 'validateArguments', 'prepareArguments', 'setViewHelperVariableContainer'));
     $mockViewHelper->expects($this->any())->method('render')->will($this->returnValue('String'));
     $viewHelperNode = new Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode($mockViewHelper, array());
     $mockViewHelperArguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
     $this->mockObjectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
     $this->mockObjectManager->expects($this->at(1))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
     $viewHelperNode->evaluate($this->renderingContext);
     $viewHelperNode->evaluate($this->renderingContext);
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
     $response = $this->getMock('Tx_Extbase_MVC_Web_Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('Tx_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);
 }