[BUGFIX] Fix Fluid template path issues 56/54156/2
authorHelmut Hummel <typo3@helhum.io>
Thu, 14 Sep 2017 10:53:23 +0000 (12:53 +0200)
committerHelmut Hummel <typo3@helhum.io>
Sun, 17 Sep 2017 21:09:48 +0000 (23:09 +0200)
* Widget template override also works with legacy config option
* Runtime cache is removed
* TemplatePathsTests from https://github.com/helhum/fluid_test are
  integrated

Resolves: #82344
Resolves: #82181
Resolves: #73207
Related: #82407
Releases: master, 8.7
Change-Id: Icd0a8aa3f1646315c094ad8768e2ff0bb34033d9
Reviewed-on: https://review.typo3.org/54156
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
25 files changed:
typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetController.php
typo3/sysext/fluid/Classes/View/TemplatePaths.php
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Classes/Controller/TemplateController.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/Basic.ts [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseController.ts [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbasePlugin.ts [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseTwoPlugins.ts [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/FluidTemplateContentObject.ts [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Layouts/BaseLayout.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Partials/BasePartial.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/Template/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/ViewHelpers/Widget/Paginate/Index.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/LayoutOverride/Layouts/BaseLayout.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Layouts/BaseLayout.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Layouts/BaseLayout.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Partials/BasePartial.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/Template/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/PartialOverride/Partials/BasePartial.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Partials/BasePartial.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/Template/BaseTemplate.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Functional/View/TemplatesPathsTest.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php

index 89cc9d8..19c6564 100644 (file)
@@ -65,15 +65,15 @@ abstract class AbstractWidgetController extends \TYPO3\CMS\Extbase\Mvc\Controlle
         $widgetViewConfiguration = null;
         $parentConfiguration = $view->getTemplatePaths()->toArray();
         $rootConfiguration = $templatePaths->toArray();
-        if (!isset($extbaseFrameworkConfiguration['view']['widget'][$widgetViewHelperClassName])) {
-            $widgetViewConfiguration = array_merge_recursive($parentConfiguration, $rootConfiguration);
-        } else {
-            $widgetViewConfiguration = array_merge_recursive(
-                (array) $rootConfiguration,
-                (array) $parentConfiguration,
-                (array) $extbaseFrameworkConfiguration['view']['widget'][$widgetViewHelperClassName]
-            );
+        $pluginConfiguration = $extbaseFrameworkConfiguration['view']['widget'][$widgetViewHelperClassName] ?? [];
+        if (isset($pluginConfiguration['templateRootPath']) && !isset($pluginConfiguration['templateRootPaths'])) {
+            $pluginConfiguration['templateRootPaths'][10] = $pluginConfiguration['templateRootPath'];
         }
+        $widgetViewConfiguration = array_merge_recursive(
+            (array) $rootConfiguration,
+            (array) $parentConfiguration,
+            (array) $pluginConfiguration
+        );
         $view->getTemplatePaths()->fillFromConfigurationArray($widgetViewConfiguration);
     }
 }
index 274bf47..150e975 100644 (file)
@@ -14,8 +14,6 @@ namespace TYPO3\CMS\Fluid\View;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -79,12 +77,6 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
         if (empty($extensionKey)) {
             return [];
         }
-        $cache = $this->getRuntimeCache();
-        $cacheIdentifier = 'viewpaths_' . $extensionKey;
-        $configuration = $cache->get($cacheIdentifier);
-        if (!empty($configuration)) {
-            return $configuration;
-        }
 
         $resources = $this->getExtensionPrivateResourcesPath($extensionKey);
         $paths = [
@@ -125,8 +117,6 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
             }
         }
 
-        $cache->set($cacheIdentifier, $paths);
-
         return $paths;
     }
 
@@ -235,12 +225,4 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
     {
         return TYPO3_MODE === 'FE';
     }
-
-    /**
-     * @return VariableFrontend
-     */
-    protected function getRuntimeCache()
-    {
-        return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime');
-    }
 }
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Classes/Controller/TemplateController.php b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Classes/Controller/TemplateController.php
new file mode 100644 (file)
index 0000000..af06dde
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+namespace TYPO3Fluid\FluidTest\Controller;
+
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+
+/**
+ * Class TemplateController
+ */
+class TemplateController extends ActionController
+{
+    public function baseTemplateAction()
+    {
+        $this->view->assign('objects', ['foo']);
+    }
+}
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/Basic.ts b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/Basic.ts
new file mode 100644 (file)
index 0000000..310773b
--- /dev/null
@@ -0,0 +1,115 @@
+config {
+    no_cache = 1
+    debug = 0
+    xhtml_cleaning = 0
+    admPanel = 0
+    disableAllHeaderCode = 1
+    sendCacheHeaders = 0
+    sys_language_uid = 0
+    sys_language_mode = ignore
+    sys_language_overlay = 1
+    absRefPrefix = /
+    linkVars = L
+    contentObjectExceptionHandler = 0
+    intTarget = _blank
+}
+
+page = PAGE
+page.config.no_cache = 0
+page.config.contentObjectExceptionHandler = 0
+
+lib.viewConfig {
+    templateRootPaths {
+        1 = EXT:fluid_test/Resources/Private/Base/Templates/
+    }
+
+    partialRootPaths {
+        1 = EXT:fluid_test/Resources/Private/Base/Partials/
+    }
+
+    layoutRootPaths {
+        1 = EXT:fluid_test/Resources/Private/Base/Layouts/
+    }
+
+    widget.TYPO3\CMS\Fluid\ViewHelpers\Widget\PaginateViewHelper {
+        templateRootPath = EXT:fluid_test/Resources/Private/Base/Templates/
+        templateRootPaths {
+            1 = EXT:fluid_test/Resources/Private/Base/Templates/
+        }
+    }
+}
+
+[globalVar = GP:override = overrideAll]
+    lib.viewConfig {
+        templateRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Templates/
+        }
+
+        partialRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Partials/
+        }
+
+        layoutRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Layouts/
+        }
+    }
+[end]
+
+[globalVar = GP:override = templateOverride]
+    lib.viewConfig {
+        templateRootPaths {
+            15 = EXT:fluid_test/Resources/Private/TemplateOverride/Templates/
+            10 = EXT:fluid_test/Resources/Private/Override/Templates/
+        }
+    }
+[end]
+
+[globalVar = GP:override = templateOverrideManual]
+    lib.viewConfig {
+        templateRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Templates/
+            bla = EXT:fluid_test/Resources/Private/TemplateOverride/Templates/
+        }
+    }
+[end]
+
+[globalVar = GP:override = partialOverride]
+    lib.viewConfig {
+        partialRootPaths {
+            15 = EXT:fluid_test/Resources/Private/PartialOverride/Partials/
+            10 = EXT:fluid_test/Resources/Private/Override/Partials/
+        }
+    }
+[end]
+
+[globalVar = GP:override = partialOverrideManual]
+    lib.viewConfig {
+        partialRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Partials/
+            bla = EXT:fluid_test/Resources/Private/PartialOverride/Partials/
+        }
+    }
+[end]
+
+[globalVar = GP:override = layoutOverride]
+    lib.viewConfig {
+        layoutRootPaths {
+            15 = EXT:fluid_test/Resources/Private/LayoutOverride/Layouts/
+            10 = EXT:fluid_test/Resources/Private/Override/Layouts/
+        }
+    }
+[end]
+
+[globalVar = GP:override = layoutOverrideManual]
+    lib.viewConfig {
+        layoutRootPaths {
+            10 = EXT:fluid_test/Resources/Private/Override/Layouts/
+            bla = EXT:fluid_test/Resources/Private/LayoutOverride/Layouts/
+        }
+    }
+[end]
+
+<INCLUDE_TYPOSCRIPT: source="FILE: ./FluidTemplateContentObject.ts" condition="[globalVar = GP:mode = fluidTemplate]">
+<INCLUDE_TYPOSCRIPT: source="FILE: ./ExtbasePlugin.ts" condition="[globalVar = GP:mode = plugin]">
+<INCLUDE_TYPOSCRIPT: source="FILE: ./ExtbaseController.ts" condition="[globalVar = GP:mode = controller]">
+<INCLUDE_TYPOSCRIPT: source="FILE: ./ExtbaseTwoPlugins.ts" condition="[globalVar = GP:mode = 2plugins]">
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseController.ts b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseController.ts
new file mode 100644 (file)
index 0000000..4f5d4ce
--- /dev/null
@@ -0,0 +1,16 @@
+page.10 = USER
+page.10 {
+    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
+    extensionName = FluidTest
+    pluginName = Pi
+    vendorName = TYPO3Fluid
+    view < lib.viewConfig
+}
+
+[globalVar = GP:widgetConfig = new]
+    page.10.view.widget.TYPO3\CMS\Fluid\ViewHelpers\Widget\PaginateViewHelper.templateRootPath >
+[end]
+
+[globalVar = GP:widgetConfig = old]
+    page.10.view.widget.TYPO3\CMS\Fluid\ViewHelpers\Widget\PaginateViewHelper.templateRootPaths >
+[end]
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbasePlugin.ts b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbasePlugin.ts
new file mode 100644 (file)
index 0000000..09e8993
--- /dev/null
@@ -0,0 +1,21 @@
+page.10 = USER
+page.10 {
+    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
+    extensionName = FluidTest
+    pluginName = Pi
+    vendorName = TYPO3Fluid
+}
+
+[globalVar = GP:pluginConfig = extensionKey]
+    plugin.tx_fluidtest.view < lib.viewConfig
+[end]
+
+[globalVar = GP:pluginConfig = pluginName]
+    plugin.tx_fluidtest_pi.view < lib.viewConfig
+[end]
+
+[globalVar = GP:pluginConfig = incomplete]
+    plugin.tx_fluidtest_pi.view < lib.viewConfig
+    plugin.tx_fluidtest_pi.view.partialRootPaths >
+    plugin.tx_fluidtest_pi.view.layoutRootPaths >
+[end]
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseTwoPlugins.ts b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/ExtbaseTwoPlugins.ts
new file mode 100644 (file)
index 0000000..cc22765
--- /dev/null
@@ -0,0 +1,14 @@
+page.10 = USER
+page.10 {
+    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
+    extensionName = FluidTest
+    pluginName = Pi
+    vendorName = TYPO3Fluid
+    view < lib.viewConfig
+}
+
+page.20 < page.10
+page.20.view.templateRootPaths >
+page.20.view.templateRootPaths.1 = EXT:fluid_test/Resources/Private/Override/Templates/
+
+
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/FluidTemplateContentObject.ts b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Configuration/TypoScript/FluidTemplateContentObject.ts
new file mode 100644 (file)
index 0000000..33c8512
--- /dev/null
@@ -0,0 +1,3 @@
+page.10 = FLUIDTEMPLATE
+page.10 < lib.viewConfig
+page.10.templateName = BaseTemplate
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Layouts/BaseLayout.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Layouts/BaseLayout.html
new file mode 100644 (file)
index 0000000..957cf07
--- /dev/null
@@ -0,0 +1,10 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+Base Layout
+<f:render section="main" />
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Partials/BasePartial.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Partials/BasePartial.html
new file mode 100644 (file)
index 0000000..1e8c2f6
--- /dev/null
@@ -0,0 +1,11 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:section name="main">
+    Base Partial
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/BaseTemplate.html
new file mode 100644 (file)
index 0000000..8fc8643
--- /dev/null
@@ -0,0 +1,14 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    Base Template
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/Template/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/Template/BaseTemplate.html
new file mode 100644 (file)
index 0000000..f3d2610
--- /dev/null
@@ -0,0 +1,16 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    <f:widget.paginate objects="{objects}" as="object">
+    </f:widget.paginate>
+    Base Template
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/ViewHelpers/Widget/Paginate/Index.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Base/Templates/ViewHelpers/Widget/Paginate/Index.html
new file mode 100644 (file)
index 0000000..868c185
--- /dev/null
@@ -0,0 +1 @@
+PAGINATE WIDGET
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/LayoutOverride/Layouts/BaseLayout.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/LayoutOverride/Layouts/BaseLayout.html
new file mode 100644 (file)
index 0000000..ce8928a
--- /dev/null
@@ -0,0 +1,10 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+LayoutOverride
+<f:render section="main" />
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Layouts/BaseLayout.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Layouts/BaseLayout.html
new file mode 100644 (file)
index 0000000..b1af7c4
--- /dev/null
@@ -0,0 +1,10 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+Default Layout
+<f:render section="main" />
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Layouts/BaseLayout.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Layouts/BaseLayout.html
new file mode 100644 (file)
index 0000000..136bff9
--- /dev/null
@@ -0,0 +1,10 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+Override Layout
+<f:render section="main" />
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Partials/BasePartial.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Partials/BasePartial.html
new file mode 100644 (file)
index 0000000..6afe764
--- /dev/null
@@ -0,0 +1,11 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:section name="main">
+    Override Partial
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/BaseTemplate.html
new file mode 100644 (file)
index 0000000..3e2ab42
--- /dev/null
@@ -0,0 +1,14 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    Override Template
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/Template/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Override/Templates/Template/BaseTemplate.html
new file mode 100644 (file)
index 0000000..3e2ab42
--- /dev/null
@@ -0,0 +1,14 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    Override Template
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/PartialOverride/Partials/BasePartial.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/PartialOverride/Partials/BasePartial.html
new file mode 100644 (file)
index 0000000..d8e130a
--- /dev/null
@@ -0,0 +1,11 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:section name="main">
+    PartialOverride
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Partials/BasePartial.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/Partials/BasePartial.html
new file mode 100644 (file)
index 0000000..e822e14
--- /dev/null
@@ -0,0 +1,11 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:section name="main">
+    Default Partial
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/BaseTemplate.html
new file mode 100644 (file)
index 0000000..31a52d2
--- /dev/null
@@ -0,0 +1,14 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    TemplateOverride
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/Template/BaseTemplate.html b/typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/Resources/Private/TemplateOverride/Templates/Template/BaseTemplate.html
new file mode 100644 (file)
index 0000000..31a52d2
--- /dev/null
@@ -0,0 +1,14 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
+      xmlns:f="http://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers">
+
+<body>
+
+<f:layout name="BaseLayout" />
+
+<f:section name="main">
+    TemplateOverride
+    <f:render partial="BasePartial" section="main"/>
+</f:section>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/Functional/View/TemplatesPathsTest.php b/typo3/sysext/fluid/Tests/Functional/View/TemplatesPathsTest.php
new file mode 100644 (file)
index 0000000..f055cda
--- /dev/null
@@ -0,0 +1,318 @@
+<?php
+namespace TYPO3\Fluid\Tests\Functional\View;
+
+use PHPUnit\Util\PHP\AbstractPhpProcess;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Response;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
+
+class TemplatesPathsTest extends FunctionalTestCase
+{
+    /**
+     * @var array
+     */
+    protected $testExtensionsToLoad = [
+        'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
+    ];
+
+    /**
+     * @var array
+     */
+    protected $coreExtensionsToLoad = [
+        'fluid',
+    ];
+
+    /**
+     * @var array
+     */
+    protected $configurationToUseInTestInstance = [
+        'EXTCONF' => [
+            'extbase' => [
+                'extensions' => [
+                    'FluidTest' => [
+                        'plugins' => [
+                            'Pi' => [
+                                'controllers' => [
+                                    'Template' => [
+                                        'actions' => [
+                                            'baseTemplate',
+                                        ],
+                                        'nonCacheableActions' => [
+                                            'baseTemplate',
+                                        ],
+                                    ],
+                                ],
+                            ],
+                        ],
+                    ],
+                ],
+            ],
+        ],
+    ];
+
+    public function setUp()
+    {
+        parent::setUp();
+
+        $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
+        $this->setUpFrontendRootPage(1, ['EXT:fluid_test/Configuration/TypoScript/Basic.ts']);
+    }
+
+    /**
+     * @return array
+     */
+    public function differentOverrideScenariosDataProvider(): array
+    {
+        return [
+            'base' => [
+                'base',
+                'Base Template',
+                'Base Partial',
+                'Base Layout',
+            ],
+            'overrideAll' => [
+                'overrideAll',
+                'Override Template',
+                'Override Partial',
+                'Override Layout',
+            ],
+            'templateOverride' => [
+                'templateOverride',
+                'TemplateOverride',
+                'Base Partial',
+                'Base Layout',
+            ],
+            'templateOverrideManual' => [
+                'templateOverrideManual',
+                'TemplateOverride',
+                'Base Partial',
+                'Base Layout',
+            ],
+            'partialOverride' => [
+                'partialOverride',
+                'Base Template',
+                'PartialOverride',
+                'Base Layout',
+            ],
+            'partialOverrideManual' => [
+                'partialOverrideManual',
+                'Base Template',
+                'PartialOverride',
+                'Base Layout',
+            ],
+            'layoutOverride' => [
+                'layoutOverride',
+                'Base Template',
+                'Base Partial',
+                'LayoutOverride',
+            ],
+            'layoutOverrideManual' => [
+                'layoutOverrideManual',
+                'Base Template',
+                'Base Partial',
+                'LayoutOverride',
+            ],
+        ];
+    }
+
+    /**
+     * @test
+     * @param string $overrideType
+     * @param string $expectedTemplate
+     * @param string $expectedPartial
+     * @param string $expectedLayout
+     * @dataProvider differentOverrideScenariosDataProvider
+     */
+    public function baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => $overrideType,
+            'mode' => 'fluidTemplate',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains($expectedTemplate, $content);
+        $this->assertContains($expectedPartial, $content);
+        $this->assertContains($expectedLayout, $content);
+    }
+
+    /**
+     * @test
+     * @param string $overrideType
+     * @param string $expectedTemplate
+     * @param string $expectedPartial
+     * @param string $expectedLayout
+     * @dataProvider differentOverrideScenariosDataProvider
+     */
+    public function baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => $overrideType,
+            'mode' => 'controller',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains($expectedTemplate, $content);
+        $this->assertContains($expectedPartial, $content);
+        $this->assertContains($expectedLayout, $content);
+    }
+
+    /**
+     * @test
+     * @param string $overrideType
+     * @param string $expectedTemplate
+     * @param string $expectedPartial
+     * @param string $expectedLayout
+     * @dataProvider differentOverrideScenariosDataProvider
+     */
+    public function baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => $overrideType,
+            'mode' => 'plugin',
+            'pluginConfig' => 'extensionKey',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains($expectedTemplate, $content);
+        $this->assertContains($expectedPartial, $content);
+        $this->assertContains($expectedLayout, $content);
+    }
+
+    /**
+     * @test
+     * @param string $overrideType
+     * @param string $expectedTemplate
+     * @param string $expectedPartial
+     * @param string $expectedLayout
+     * @dataProvider differentOverrideScenariosDataProvider
+     */
+    public function baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => $overrideType,
+            'mode' => 'plugin',
+            'pluginConfig' => 'pluginName',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains($expectedTemplate, $content);
+        $this->assertContains($expectedPartial, $content);
+        $this->assertContains($expectedLayout, $content);
+    }
+
+    /**
+     * @test
+     */
+    public function widgetTemplateCanBeOverridden()
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => 'base',
+            'mode' => 'controller',
+            'widgetConfig' => 'new',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains('PAGINATE WIDGET', $content);
+    }
+
+    /**
+     * @test
+     */
+    public function widgetTemplateCanBeOverriddenWithLegacyConfig()
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => 'base',
+            'mode' => 'controller',
+            'widgetConfig' => 'old',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains('PAGINATE WIDGET', $content);
+    }
+
+    /**
+     * @test
+     */
+    public function baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig()
+    {
+        $requestArguments = [
+            'id' => '1',
+            'override' => 'base',
+            'mode' => 'plugin',
+            'pluginConfig' => 'incomplete',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains('Base Template', $content);
+        $this->assertContains('Default Layout', $content);
+        $this->assertContains('Default Partial', $content);
+    }
+
+    /**
+     * @test
+     */
+    public function baseRenderingWorksForControllerWithTwoPlugins()
+    {
+        $requestArguments = [
+            'id' => '1',
+            'mode' => '2plugins',
+        ];
+
+        $content = $this->fetchFrontendResponse($requestArguments)->getContent();
+
+        $this->assertContains('Base Template', $content);
+        $this->assertContains('Override Template', $content);
+    }
+
+    /**
+     * @param array $requestArguments
+     * @param bool $failOnFailure
+     * @return Response
+     */
+    protected function fetchFrontendResponse(array $requestArguments, $failOnFailure = true)
+    {
+        $arguments = [
+            'documentRoot' => $this->instancePath,
+            'requestUrl' => 'http://localhost' . '/?' . GeneralUtility::implodeArrayForUrl('', $requestArguments),
+        ];
+
+        $template = new \Text_Template(TYPO3_PATH_PACKAGES . 'typo3/testing-framework/Resources/Core/Functional/Fixtures/Frontend/request.tpl');
+        $template->setVar(
+            [
+                'arguments' => var_export($arguments, true),
+                'originalRoot' => ORIGINAL_ROOT,
+                'vendorPath' => TYPO3_PATH_PACKAGES,
+            ]
+        );
+
+        $php = AbstractPhpProcess::factory();
+        $response = $php->runJob($template->render());
+        $result = json_decode($response['stdout'], true);
+
+        if ($result === null) {
+            $this->fail('Frontend Response is empty');
+        }
+
+        if ($failOnFailure && $result['status'] === Response::STATUS_Failure) {
+            $this->fail('Frontend Response has failure:' . LF . $result['error']);
+        }
+
+        $response = new Response($result['status'], $result['content'], $result['error']);
+
+        return $response;
+    }
+}
index bfb3c2c..4eb712c 100644 (file)
@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\View;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Fluid\View\TemplatePaths;
 
@@ -130,13 +129,9 @@ class TemplatePathsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                 ]
             ]
         ]);
-        $cache = $this->getMockBuilder(VariableFrontend::class)->setMethods(['get', 'set'])->disableOriginalConstructor()->getMock();
-        $cache->expects($this->once())->method('get')->willReturn(false);
-        $cache->expects($this->once())->method('set');
         $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock();
         $subject->expects($this->once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/');
         $subject->expects($this->once())->method('getConfigurationManager')->willReturn($configurationManager);
-        $subject->expects($this->once())->method('getRuntimeCache')->willReturn($cache);
         $subject->expects($this->once())->method('isBackendMode')->willReturn(false);
         $subject->expects($this->once())->method('isFrontendMode')->willReturn(true);
         $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test');
@@ -191,13 +186,9 @@ class TemplatePathsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                 ]
             ]
         ]);
-        $cache = $this->getMockBuilder(VariableFrontend::class)->setMethods(['get', 'set'])->disableOriginalConstructor()->getMock();
-        $cache->expects($this->once())->method('get')->willReturn(false);
-        $cache->expects($this->once())->method('set');
         $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock();
         $subject->expects($this->once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/');
         $subject->expects($this->once())->method('getConfigurationManager')->willReturn($configurationManager);
-        $subject->expects($this->once())->method('getRuntimeCache')->willReturn($cache);
         $subject->expects($this->once())->method('isBackendMode')->willReturn(true);
         $subject->expects($this->never())->method('isFrontendMode');
         $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test');
@@ -252,13 +243,9 @@ class TemplatePathsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                 ]
             ]
         ]);
-        $cache = $this->getMockBuilder(VariableFrontend::class)->setMethods(['get', 'set'])->disableOriginalConstructor()->getMock();
-        $cache->expects($this->once())->method('get')->willReturn(false);
-        $cache->expects($this->never())->method('set');
         $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock();
         $subject->expects($this->once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/');
         $subject->expects($this->once())->method('getConfigurationManager')->willReturn($configurationManager);
-        $subject->expects($this->once())->method('getRuntimeCache')->willReturn($cache);
         $subject->expects($this->once())->method('isBackendMode')->willReturn(false);
         $subject->expects($this->once())->method('isFrontendMode')->willReturn(false);
         $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test');