From 7a7c0e1b08eb75b0e5b48d235b57689255a174d9 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sun, 18 Aug 2024 12:28:46 +0200 Subject: [PATCH] [BUGFIX] Prevent interference between functional tests The cache is now removed between each test case, not between each test class. This also unveiled one interference between two `ForViewHelper` test cases. Further interference is still present due to Fluid's runtime cache. This is now documented in #975 to be fixed later. --- tests/Functional/AbstractFunctionalTestCase.php | 4 ++-- tests/Functional/ViewHelpers/ForViewHelperTest.php | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/Functional/AbstractFunctionalTestCase.php b/tests/Functional/AbstractFunctionalTestCase.php index 448bfe4c8..614089a6c 100644 --- a/tests/Functional/AbstractFunctionalTestCase.php +++ b/tests/Functional/AbstractFunctionalTestCase.php @@ -36,14 +36,14 @@ abstract class AbstractFunctionalTestCase extends TestCase */ protected static string $cachePath; - public static function setUpBeforeClass(): void + public function setUp(): void { self::$cachePath = sys_get_temp_dir() . '/' . 'fluid-functional-tests-' . hash('xxh3', __CLASS__); mkdir(self::$cachePath); self::$cache = (new SimpleFileCache(self::$cachePath)); } - public static function tearDownAfterClass(): void + public function tearDown(): void { self::$cache->flush(); rmdir(self::$cachePath); diff --git a/tests/Functional/ViewHelpers/ForViewHelperTest.php b/tests/Functional/ViewHelpers/ForViewHelperTest.php index 92fa60a67..453514c8b 100644 --- a/tests/Functional/ViewHelpers/ForViewHelperTest.php +++ b/tests/Functional/ViewHelpers/ForViewHelperTest.php @@ -11,7 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3Fluid\Fluid\Core\ViewHelper\Exception; use TYPO3Fluid\Fluid\Tests\Functional\AbstractFunctionalTestCase; use TYPO3Fluid\Fluid\View\TemplateView; @@ -32,8 +31,8 @@ public function renderThrowsExceptionIfSubjectIsNotTraversable(): void #[Test] public function renderThrowsExceptionIfSubjectIsInvalid(): void { - $this->expectException(Exception::class); - $this->expectExceptionCode(1248728393); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionCode(1256475113); $view = new TemplateView(); $view->assignMultiple(['value' => new \stdClass()]); $view->getRenderingContext()->setCache(self::$cache);