0fa1a7394b
SupplierPortalClient::loadSession, RefreshSupplierSessionJob, CsvReconcileJob and RouteSupplierLeadJob hardcode Cache::store('redis'), bypassing phpunit.xml's CACHE_STORE=array. Under pest --parallel every worker shares the same Memurai instance and the global supplier:session key, so one worker's afterEach forget()/flush() races another worker's mid-test loadSession() -- deterministic 1-2 failures in the tests/Feature/Supplier/ subdir-only run (quirk 72).
TestCase::setUp() repoints the redis cache store at the in-process array driver: each parallel worker gets a hermetic, worker-local cache. Production keeps the real redis driver -- the override only runs under APP_ENV=testing. New RedisCacheStoreIsolationTest guards the invariant.
Verified: tests/Feature/Supplier/ --parallel 6/6 runs 43/43 (was 42/43 +1 error); tests/Unit/Supplier/ 3/3 runs 38/38; full pest --parallel 794/791/3sk/0; Pint + Larastan clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
1020 B
PHP
26 lines
1020 B
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
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']);
|
|
}
|
|
}
|