diff --git a/app/tests/Feature/RedisCacheStoreIsolationTest.php b/app/tests/Feature/RedisCacheStoreIsolationTest.php new file mode 100644 index 00000000..c80e8e17 --- /dev/null +++ b/app/tests/Feature/RedisCacheStoreIsolationTest.php @@ -0,0 +1,24 @@ +getStore())->toBeInstanceOf(ArrayStore::class); +}); diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index fe1ffc2f..e5f98cf4 100644 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -6,5 +6,20 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { - // + protected function setUp(): void + { + parent::setUp(); + + // Quirk 72: supplier code (SupplierPortalClient::loadSession, + // RefreshSupplierSessionJob, CsvReconcileJob, RouteSupplierLeadJob) + // hardcodes Cache::store('redis'), bypassing phpunit.xml's + // CACHE_STORE=array. The Redis store is a shared external service — + // under `pest --parallel` every worker collides on the global + // `supplier:session` key, so one worker's afterEach forget()/flush() + // races another worker's mid-test loadSession(). Repoint the `redis` + // cache store at the in-process `array` driver: each worker then gets + // a hermetic, worker-local cache. Production keeps the real `redis` + // driver — this override only ever runs under APP_ENV=testing. + config(['cache.stores.redis.driver' => 'array']); + } }