/**
  * @test
  */
 public function buildBackendUriCreatesAbsoluteUrisIfSpecified()
 {
     t3lib_div::_GETset(array('M' => 'moduleKey'));
     $this->mockRequest->expects($this->any())->method('getBaseURI')->will($this->returnValue('http://baseuri/' . TYPO3_mainDir));
     $this->uriBuilder->setCreateAbsoluteUri(TRUE);
     $expectedResult = 'http://baseuri/' . TYPO3_mainDir . 'mod.php?M=moduleKey';
     $actualResult = $this->uriBuilder->buildBackendUri();
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * @test
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function getPartialSourceReturnsContentOfDefaultPartialFileIfNoPartialExistsForTheSpecifiedFormat()
 {
     $partialRootPath = dirname(__FILE__) . '/Fixtures';
     $this->view->setPartialRootPath($partialRootPath);
     $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
     $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture');
     $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * @test
  */
 public function buildSetsFormatFromGetAndPostVariables()
 {
     $this->configuration['extensionName'] = 'SomeExtensionName';
     $this->configuration['pluginName'] = 'SomePluginName';
     $this->injectDependencies();
     $_GET = array('tx_someextensionname_somepluginname' => array('format' => 'GET'));
     $_POST = array('tx_someextensionname_somepluginname' => array('format' => 'POST'));
     $this->mockRequest->expects($this->at(7))->method('setFormat')->with('POST');
     $this->requestBuilder->build();
 }
 /**
  * @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);
 }