/** * @test */ public function convertDomainObjectsToIdentityArraysConvertsDomainObjects() { $mockDomainObject1 = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_DomainObject_AbstractEntity'), array('dummy')); $mockDomainObject1->_set('uid', '123'); $mockDomainObject2 = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_DomainObject_AbstractEntity'), array('dummy')); $mockDomainObject2->_set('uid', '321'); $expectedResult = array('foo' => array('bar' => 'baz'), 'domainObject1' => '123', 'second' => array('domainObject2' => '321')); $actualResult = $this->uriBuilder->_call('convertDomainObjectsToIdentityArrays', array('foo' => array('bar' => 'baz'), 'domainObject1' => $mockDomainObject1, 'second' => array('domainObject2' => $mockDomainObject2))); $this->assertEquals($expectedResult, $actualResult); }
/** * Forwards the request to another action and / or controller. * * NOTE: This method only supports web requests and will thrown an exception * if used with other request types. * * @param string $actionName Name of the action to forward to * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used. * @param string $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed. * @param Tx_Extbase_MVC_Controller_Arguments $arguments Arguments to pass to the target action * @param integer $pageUid Target page uid. If NULL, the current page uid is used * @param integer $delay (optional) The delay in seconds. Default is no delay. * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other" * @return void * @throws Tx_Extbase_MVC_Exception_UnsupportedRequestType If the request is not a web request * @throws Tx_Extbase_MVC_Exception_StopAction * @api */ protected function redirect($actionName, $controllerName = NULL, $extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay = 0, $statusCode = 303) { if (!$this->request instanceof Tx_Extbase_MVC_Web_Request) { throw new Tx_Extbase_MVC_Exception_UnsupportedRequestType('redirect() only supports web requests.', 1220539734); } if ($controllerName === NULL) { $controllerName = $this->request->getControllerName(); } $uri = $this->uriBuilder->reset()->setTargetPageUid($pageUid)->uriFor($actionName, $arguments, $controllerName, $extensionName); $this->redirectToURI($uri, $delay, $statusCode); }
/** * Returns a frontend URI independently of current context, with or without extbase, and with or without TSFE * @param string $actionName * @param array $controllerArguments * @param string $controllerName * @param string $extensionName * @param string $pluginName * @return string absolute URI */ public static function buildFrontendUri($actionName, array $controllerArguments, $controllerName, $extensionName = 'newsletter', $pluginName = 'p') { if (!self::$uriBuilder) { self::$uriBuilder = self::buildUriBuilder($extensionName, $pluginName); } $controllerArguments['action'] = $actionName; $controllerArguments['controller'] = $controllerName; $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager'); $extensionService = $objectManager->get('Tx_Extbase_Service_ExtensionService'); $pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName); $arguments = array($pluginNamespace => $controllerArguments); self::$uriBuilder->reset()->setUseCacheHash(FALSE)->setCreateAbsoluteUri(TRUE)->setArguments($arguments); return self::$uriBuilder->buildFrontendUri() . '&type=1342671779'; }
/** * @return void * @author Sebastian Kurfürst <*****@*****.**> */ public function setUp() { $this->viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer'); $this->templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'); $this->uriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_UriBuilder'); $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder)); $this->request = $this->getMock('Tx_Extbase_MVC_Web_Request'); $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE); $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder)); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $this->tagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder'); $this->arguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE); }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function constructorInjectsRequestToUriBuilder() { $this->mockUriBuilder->expects($this->once())->method('setRequest')->with($this->mockRequest); new Tx_Fluid_View_StandaloneView(); }