From 6a56401bbcc5e2f41c0b470a7b79a4d7e59aa267 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 22 Aug 2026 12:03:19 +0100 Subject: [PATCH] [Tests] Isolate ApplicationFileProcessorTest cache dir to survive parallel chunk clears --- .../ApplicationFileProcessorTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Application/ApplicationFileProcessor/ApplicationFileProcessorTest.php b/tests/Application/ApplicationFileProcessor/ApplicationFileProcessorTest.php index 286a9b64ef9..3018a5c3833 100644 --- a/tests/Application/ApplicationFileProcessor/ApplicationFileProcessorTest.php +++ b/tests/Application/ApplicationFileProcessor/ApplicationFileProcessorTest.php @@ -4,8 +4,13 @@ namespace Rector\Tests\Application\ApplicationFileProcessor; +use Illuminate\Container\Container; use Rector\Application\ApplicationFileProcessor; +use Rector\Caching\Cache; +use Rector\Caching\CacheFactory; use Rector\Caching\Detector\ChangedFilesDetector; +use Rector\Configuration\Option; +use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector; use Rector\Testing\PHPUnit\AbstractLazyTestCase; use Rector\ValueObject\Configuration; @@ -20,6 +25,19 @@ protected function setUp(): void { parent::setUp(); + // isolate the cache directory to this test - the default directory is shared across all + // parallel test chunks, and FileCacheStorage::clear() deletes the whole directory, so a + // sibling chunk can wipe this test's cache between save and load and flip the assertions + $rectorConfig = self::getContainer(); + SimpleParameterProvider::setParameter( + Option::CACHE_DIR, + sys_get_temp_dir() . '/rector_test_application_file_processor' + ); + $rectorConfig->singleton( + Cache::class, + static fn (Container $container): Cache => $container->make(CacheFactory::class)->create() + ); + $this->applicationFileProcessor = $this->make(ApplicationFileProcessor::class); $this->changedFilesDetector = $this->make(ChangedFilesDetector::class); }