/**
  * @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);
     $this->renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContext');
 }
 /**
  * Build parser configuration
  *
  * @return Tx_Fluid_Core_Parser_Configuration
  * @author Karsten Dambekalns <*****@*****.**>
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->create('Tx_Fluid_Core_Parser_Configuration');
     if ($this->controllerContext->getRequest()->getFormat() === 'html') {
         $parserConfiguration->addInterceptor($this->objectManager->get('Tx_Fluid_Core_Parser_Interceptor_Escape'));
     }
     return $parserConfiguration;
 }
Example #3
0
 /**
  * Retrieves a repository based on the supplied entity's name.
  *
  * @param  string $entityName                         The entity's name-
  * @return Tx_Extbase_Persistence_RepositoryInterface A repository.
  * @throws Tx_Powered_Exception_NoSuchRepository      If the asked repository
  *                                                    can not be found.
  * @author Romain Ruetschi <*****@*****.**>
  */
 public function getRepository($entityName)
 {
     // If there is no already registered repository for the supplied entity's name,
     if (!isset($this->repositories[$entityName])) {
         // Prepare the replacements.
         // 1. Replace "@extension" with the extension name.
         // 2. Replace "@entity" with the "ucfirsted" entity's name.
         $replacements = array('@extension' => $this->controllerContext->getRequest()->getControllerExtensionName(), '@entity' => ucfirst($entityName));
         // Build the repository class name.
         $repositoryClassName = str_replace(array_keys($replacements), array_values($replacements), $this->repositoryClassNamePattern);
         // If the class is not defined (so it does not exists),
         if (!class_exists($repositoryClassName)) {
             throw new Tx_Powered_Exception_NoSuchRepository('The repository "' . $repositoryClassName . '" cannot be found.');
         }
         // Else, store a reference to the unique instance of the repository
         $this->repositories[$entityName] = t3lib_div::makeInstance($repositoryClassName);
     }
     // Return the stored reference.
     return $this->repositories[$entityName];
 }
 /**
  * @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);
 }
 /**
  * @test
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function constructorInjectsFlashMessageContainerToControllerContext()
 {
     $this->mockControllerContext->expects($this->once())->method('setFlashMessageContainer')->with($this->mockFlashMessages);
     new Tx_Fluid_View_StandaloneView();
 }