[TASK] Make FluidTemplateContentObjectTest notice free 04/57904/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 14 Aug 2018 19:31:52 +0000 (21:31 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 14 Aug 2018 19:55:54 +0000 (21:55 +0200)
Resolves: #85853
Releases: master
Change-Id: I53677566e9b2af971fafed47e4d6f0a0669911bd
Reviewed-on: https://review.typo3.org/57904
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index d836d5d..6acd887 100644 (file)
@@ -172,7 +172,9 @@ class FluidTemplateContentObject extends AbstractContentObject
             $this->view->setTemplateSource($templateSource);
         } else {
             // Fetch the Fluid template by file stdWrap
-            $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
+            $file = isset($conf['file.'])
+                ? $this->cObj->stdWrap($conf['file'] ?? '', $conf['file.'])
+                : ($conf['file'] ?? '');
             // Get the absolute file name
             $templatePathAndFilename = GeneralUtility::getFileAbsFileName($file);
             $this->view->setTemplatePathAndFilename($templatePathAndFilename);
@@ -231,7 +233,9 @@ class FluidTemplateContentObject extends AbstractContentObject
      */
     protected function setFormat(array $conf)
     {
-        $format = isset($conf['format.']) ? $this->cObj->stdWrap($conf['format'], $conf['format.']) : $conf['format'];
+        $format = isset($conf['format.'])
+            ? $this->cObj->stdWrap($conf['format'] ?? '', $conf['format.'])
+            : ($conf['format'] ?? '');
         if ($format) {
             $this->view->setFormat($format);
         }
@@ -245,19 +249,27 @@ class FluidTemplateContentObject extends AbstractContentObject
     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'];
+        $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'];
+        $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'];
+        $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'];
+        $requestControllerActionName = isset($conf['extbase.']['controllerActionName.'])
+            ? $this->cObj->stdWrap($conf['extbase.']['controllerActionName'] ?? '', $conf['extbase.']['controllerActionName.'])
+            : ($conf['extbase.']['controllerActionName'] ?? '');
         if ($requestControllerActionName) {
             $this->view->getRequest()->setControllerActionName($requestControllerActionName);
         }
@@ -301,7 +313,7 @@ class FluidTemplateContentObject extends AbstractContentObject
         $variables = [];
         $reservedVariables = ['data', 'current'];
         // Accumulate the variables to be process and loop them through cObjGetSingle
-        $variablesToProcess = (array)$conf['variables.'];
+        $variablesToProcess = (array)($conf['variables.'] ?? []);
         foreach ($variablesToProcess as $variableName => $cObjType) {
             if (is_array($cObjType)) {
                 continue;
@@ -316,7 +328,7 @@ class FluidTemplateContentObject extends AbstractContentObject
             }
         }
         $variables['data'] = $this->cObj->data;
-        $variables['current'] = $this->cObj->data[$this->cObj->currentValKey];
+        $variables['current'] = $this->cObj->data[$this->cObj->currentValKey ?? null] ?? null;
         return $variables;
     }
 
index c59d5c0..7ddbf87 100644 (file)
@@ -24,19 +24,15 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 use TYPO3Fluid\Fluid\View\TemplateView;
 
 /**
  * Testcase
  */
-class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FluidTemplateContentObjectTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var bool Reset singletons created by subject
      */
     protected $resetSingletonInstances = true;
@@ -76,7 +72,9 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         );
         /** @var $tsfe TypoScriptFrontendController */
         $tsfe = $this->createMock(TypoScriptFrontendController::class);
-        $tsfe->tmpl = $this->getMockBuilder(TemplateService::class)->getMock();
+        $tsfe->tmpl = $this->getMockBuilder(TemplateService::class)
+            ->disableOriginalConstructor(true)
+            ->getMock();
         $GLOBALS['TSFE'] = $tsfe;
     }