Пример #1
0
 /**
  * @param bool $isActionCacheable
  * @param bool $requestIsCached
  * @param bool $expectedUseCacheHash
  * @test
  * @dataProvider uriForDisablesCacheHashIfPossibleDataProvider
  */
 public function uriForDisablesCacheHashIfPossible($isActionCacheable, $requestIsCached, $expectedUseCacheHash)
 {
     $this->mockExtensionService->expects($this->once())->method('isActionCacheable')->will($this->returnValue($isActionCacheable));
     $this->mockRequest->expects($this->once())->method('isCached')->will($this->returnValue($requestIsCached));
     $this->uriBuilder->uriFor('someNonCacheableAction', array(), 'SomeController', 'SomeExtension');
     $this->assertEquals($expectedUseCacheHash, $this->uriBuilder->getUseCacheHash());
 }
Пример #2
0
 /**
  * Redirects the request to another action and / or controller.
  *
  * Redirect will be sent to the client which then performs another request to the new URI.
  *
  * 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 array $arguments Arguments to pass to the target action
  * @param int $pageUid Target page uid. If NULL, the current page uid is used
  * @param int $delay (optional) The delay in seconds. Default is no delay.
  * @param int $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other
  * @return void
  * @throws UnsupportedRequestTypeException If the request is not a web request
  * @throws StopActionException
  * @see forward()
  * @api
  */
 protected function redirect($actionName, $controllerName = null, $extensionName = null, array $arguments = null, $pageUid = null, $delay = 0, $statusCode = 303)
 {
     if (!$this->request instanceof WebRequest) {
         throw new UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734);
     }
     if ($controllerName === null) {
         $controllerName = $this->request->getControllerName();
     }
     $this->uriBuilder->reset()->setTargetPageUid($pageUid)->setCreateAbsoluteUri(true);
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
         $this->uriBuilder->setAbsoluteUriScheme('https');
     }
     $uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName);
     $this->redirectToUri($uri, $delay, $statusCode);
 }
Пример #3
0
 /**
  * @test
  */
 public function uriForDoesNotDisableCacheHashForNonCacheableActions()
 {
     $this->mockExtensionService->expects($this->any())->method('isActionCacheable')->will($this->returnValue(false));
     $this->uriBuilder->uriFor('someNonCacheableAction', array(), 'SomeController', 'SomeExtension');
     $this->assertTrue($this->uriBuilder->getUseCacheHash());
 }