Skip to content

Commit 34131d1

Browse files
authored
test: add Queue::fake() to stabilize CacheStoreTest in sync-queue environments (#416)
Three tests in CacheStoreTest (Updated/Activated/Deactivated dispatch) have failed in CI since 2026-02-25 while passing locally. Root cause: the Updated/Activated/Deactivated events each have three listeners wired (BustCacheImmediately sync, plus BustCache and BuildCache both queued). BuildCache::handle() calls repository find() which uses Cache::rememberForever() and re-populates the exact 'totem.task.{id}' key the tests assert was cleared. Whether the queued listeners execute synchronously during dispatch depends on config('queue.default'). In CI the default is 'sync' (fresh install; no vendor/orchestra/testbench-core/laravel/.env), so BuildCache runs synchronously and repopulates the cache before the assertion. Local environments that have a stale testbench-core/laravel/.env setting QUEUE_CONNECTION=database serialize the queued listeners and never execute them in tests, masking the issue. Fix: call Queue::fake() in the three affected tests. This ensures only BustCacheImmediately (the non-queued listener) runs during dispatch, which matches the tests' evident intent. The fix is test-harness-only; no src/ changes, no runtime behavior impact. Verified locally: - With vendor/.env present: 8/8 CacheStoreTest tests pass (78/78 full) - With vendor/.env removed (CI condition): 8/8 pass (78/78 full)
1 parent 4dade22 commit 34131d1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tests/Feature/CacheStoreTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Studio\Totem\Tests\Feature;
44

55
use Illuminate\Support\Facades\Cache;
6+
use Illuminate\Support\Facades\Queue;
67
use Studio\Totem\Repositories\EloquentTaskRepository;
78
use Studio\Totem\Tests\TestCase;
89

@@ -72,6 +73,7 @@ public function test_bust_cache_clears_from_configured_store()
7273
public function test_updating_task_clears_route_binding_cache()
7374
{
7475
config(['totem.cache_store' => 'totem_store']);
76+
Queue::fake();
7577

7678
$task = \Studio\Totem\Task::factory()->create();
7779
Cache::store('totem_store')->forever('totem.task.'.$task->id, $task);
@@ -86,6 +88,7 @@ public function test_updating_task_clears_route_binding_cache()
8688
public function test_activating_task_clears_route_binding_cache()
8789
{
8890
config(['totem.cache_store' => 'totem_store']);
91+
Queue::fake();
8992

9093
$task = \Studio\Totem\Task::factory()->create();
9194
Cache::store('totem_store')->forever('totem.task.'.$task->id, $task);
@@ -98,6 +101,7 @@ public function test_activating_task_clears_route_binding_cache()
98101
public function test_deactivating_task_clears_route_binding_cache()
99102
{
100103
config(['totem.cache_store' => 'totem_store']);
104+
Queue::fake();
101105

102106
$task = \Studio\Totem\Task::factory()->create();
103107
Cache::store('totem_store')->forever('totem.task.'.$task->id, $task);

0 commit comments

Comments
 (0)