From dbb0a6b4f0a20a175ee8741898dd5eccf7bb8af1 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sun, 8 Sep 2024 12:03:52 +0200 Subject: [PATCH] [TASK] Prevent template compilation in inheritance test (#999) This is an ugly workaround to prevent the interfering runtime cache until #975 is resolved. Currently, subsequent test cases are successful even if the rendering is modified to not inherit ViewHelper namespaces to sub templates because they re-use the "in-memory" template classes from previous tests. As there is currently no way to configure this, we need to use the ugly f:cache.disable ViewHelper in the affected template to get robust testing results. --- .../Rendering/NamespaceInheritanceTest.php | 22 +++++++------------ .../Layouts/NamespaceInheritanceLayout.html | 1 + .../NamespaceInheritanceNestedPartial.html | 1 + .../Partials/NamespaceInheritancePartial.html | 1 + 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/Functional/Core/Rendering/NamespaceInheritanceTest.php b/tests/Functional/Core/Rendering/NamespaceInheritanceTest.php index 2d003342c..3777a3a76 100644 --- a/tests/Functional/Core/Rendering/NamespaceInheritanceTest.php +++ b/tests/Functional/Core/Rendering/NamespaceInheritanceTest.php @@ -21,25 +21,25 @@ public static function namespacesAreInheritedToLayoutAndPartialsDataProvider(): { return [ 'namespace provided via php api' => [ - '', + '', ['test' => 'TYPO3Fluid\\Fluid\\Tests\\Functional\\Fixtures\\ViewHelpers'], [], ], // @todo this should probably not work 'namespace provided to layout and partials via inline namespace declaration in template' => [ - '{namespace test=TYPO3Fluid\\Fluid\\Tests\\Functional\\Fixtures\\ViewHelpers}', + '{namespace test=TYPO3Fluid\\Fluid\\Tests\\Functional\\Fixtures\\ViewHelpers}', [], [], ], // @todo this should probably not work 'namespace provided to layout and partials via xml namespace declaration in template' => [ - '', + '', [], [], ], // @todo this should probably not work 'namespace inherited from template to dynamic layout' => [ - '', + '', [], ['myLayout' => 'NamespaceInheritanceLayout'], ], @@ -50,7 +50,7 @@ public static function namespacesAreInheritedToLayoutAndPartialsDataProvider(): #[DataProvider('namespacesAreInheritedToLayoutAndPartialsDataProvider')] public function namespacesAreInheritedToLayoutAndPartials(string $source, array $predefinedNamespaces, array $variables): void { - $expectedResult = '
' . "\n\n" . '
' . "\n\n" . '
' . "\n\n" . '
' . "\n\n"; + $expectedResult = "\n" . '
' . "\n\n" . '
' . "\n\n\n\n" . '
' . "\n\n" . '
' . "\n\n"; // Uncached $view = new TemplateView(); @@ -62,15 +62,9 @@ public function namespacesAreInheritedToLayoutAndPartials(string $source, array $view->getRenderingContext()->getTemplatePaths()->setPartialRootPaths([__DIR__ . '/../../Fixtures/Partials/']); self::assertSame($expectedResult, $view->render()); - // Cached - $view = new TemplateView(); - $view->getRenderingContext()->setCache(self::$cache); - $view->getRenderingContext()->getViewHelperResolver()->addNamespaces($predefinedNamespaces); - $view->assignMultiple($variables); - $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($source); - $view->getRenderingContext()->getTemplatePaths()->setLayoutRootPaths([__DIR__ . '/../../Fixtures/Layouts/']); - $view->getRenderingContext()->getTemplatePaths()->setPartialRootPaths([__DIR__ . '/../../Fixtures/Partials/']); - self::assertSame($expectedResult, $view->render()); + // @todo Cached state is currently not relevant here, since caching needs to be disabled for all affected templates to get robust testing results + // With enabled caching, there is interference between the test cases because the "in-memory" cache of TemplateCompiler is re-used and thus + // test cases might be green even if they should actually be red. See https://github.com/TYPO3/Fluid/issues/975 } public static function namespaceDefinedInParentNotValidInChildrenDataProvider(): array diff --git a/tests/Functional/Fixtures/Layouts/NamespaceInheritanceLayout.html b/tests/Functional/Fixtures/Layouts/NamespaceInheritanceLayout.html index e48e6dc43..011571821 100644 --- a/tests/Functional/Fixtures/Layouts/NamespaceInheritanceLayout.html +++ b/tests/Functional/Fixtures/Layouts/NamespaceInheritanceLayout.html @@ -1,3 +1,4 @@ + diff --git a/tests/Functional/Fixtures/Partials/NamespaceInheritanceNestedPartial.html b/tests/Functional/Fixtures/Partials/NamespaceInheritanceNestedPartial.html index a3a827d82..b18095ef9 100644 --- a/tests/Functional/Fixtures/Partials/NamespaceInheritanceNestedPartial.html +++ b/tests/Functional/Fixtures/Partials/NamespaceInheritanceNestedPartial.html @@ -1 +1,2 @@ + diff --git a/tests/Functional/Fixtures/Partials/NamespaceInheritancePartial.html b/tests/Functional/Fixtures/Partials/NamespaceInheritancePartial.html index 78004768c..f90621092 100644 --- a/tests/Functional/Fixtures/Partials/NamespaceInheritancePartial.html +++ b/tests/Functional/Fixtures/Partials/NamespaceInheritancePartial.html @@ -1,2 +1,3 @@ +