/**
  * @param string $viewHelperTemplate
  * @param string $expectedOutput
  *
  * @test
  * @dataProvider viewHelperTemplateSourcesDataProvider
  */
 public function renderingTest($viewHelperTemplate, $expectedOutput)
 {
     $view = new StandaloneView();
     $view->getRenderingContext()->getViewHelperResolver()->addNamespace('ft', 'TYPO3Fluid\\FluidTest\\ViewHelpers');
     $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($viewHelperTemplate);
     $view->assign('settings', ['test' => '<strong>Bla</strong>']);
     $this->assertSame($expectedOutput, $view->render());
 }
Exemplo n.º 2
0
 /**
  * Set some extbase variables if given
  *
  * @param array $conf Configuration array
  * @return void
  */
 protected function setExtbaseVariables(array $conf)
 {
     /** @var $request \TYPO3\CMS\Extbase\Mvc\Request */
     $requestPluginName = isset($conf['extbase.']['pluginName.']) ? $this->cObj->stdWrap($conf['extbase.']['pluginName'], $conf['extbase.']['pluginName.']) : $conf['extbase.']['pluginName'];
     if ($requestPluginName) {
         $this->view->getRequest()->setPluginName($requestPluginName);
     }
     $requestControllerExtensionName = isset($conf['extbase.']['controllerExtensionName.']) ? $this->cObj->stdWrap($conf['extbase.']['controllerExtensionName'], $conf['extbase.']['controllerExtensionName.']) : $conf['extbase.']['controllerExtensionName'];
     if ($requestControllerExtensionName) {
         $this->view->getRequest()->setControllerExtensionName($requestControllerExtensionName);
     }
     $requestControllerName = isset($conf['extbase.']['controllerName.']) ? $this->cObj->stdWrap($conf['extbase.']['controllerName'], $conf['extbase.']['controllerName.']) : $conf['extbase.']['controllerName'];
     if ($requestControllerName) {
         $this->view->getRequest()->setControllerName($requestControllerName);
     }
     $requestControllerActionName = isset($conf['extbase.']['controllerActionName.']) ? $this->cObj->stdWrap($conf['extbase.']['controllerActionName'], $conf['extbase.']['controllerActionName.']) : $conf['extbase.']['controllerActionName'];
     if ($requestControllerActionName) {
         $this->view->getRequest()->setControllerActionName($requestControllerActionName);
     }
     if ($requestPluginName && $requestControllerExtensionName && $requestControllerName && $requestControllerActionName) {
         $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManager::class);
         $configurationManager->setConfiguration(['extensionName' => $requestControllerExtensionName, 'pluginName' => $requestPluginName]);
         if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$requestControllerExtensionName]['plugins'][$requestPluginName]['controllers'])) {
             $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$requestControllerExtensionName]['plugins'][$requestPluginName]['controllers'] = [$requestControllerName => ['actions' => [$requestControllerActionName]]];
         }
         $requestBuilder = GeneralUtility::makeInstance(ObjectManager::class)->get(RequestBuilder::class);
         $this->view->getRenderingContext()->getControllerContext()->setRequest($requestBuilder->build());
     }
 }