Skip to content

Commit

Permalink
[BUGFIX] Prevent interference between functional tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s2b committed Aug 18, 2024
1 parent 2f76e44 commit 7a7c0e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/Functional/AbstractFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions tests/Functional/ViewHelpers/ForViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 7a7c0e1

Please sign in to comment.