Fix intermittent CacheStoreTest failures in sync-queue CI environments - #416
Merged
Conversation
…ironments
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three tests in
tests/Feature/CacheStoreTest.phphave failed in GitHub Actions CI on12.xsince 2026-02-25 while passing on most local dev environments. This PR stabilizes them withQueue::fake(). Test-harness-only change — nosrc/modifications, no runtime behavior impact.Affected tests:
test_updating_task_clears_route_binding_cachetest_activating_task_clears_route_binding_cachetest_deactivating_task_clears_route_binding_cacheSame CI failure signature on every run:
Failed asserting that true is false.Root cause
The
Updated,Activated, andDeactivatedevents each have three listeners wired insrc/Providers/TotemEventServiceProvider.php:19-21:BustCacheImmediately— plain class, runs sync.BustCache— extendsListenerwhichimplements ShouldQueue.BuildCache— same.BuildCache::handle()calls$this->tasks->find($event->task->id), which inEloquentTaskRepository::find()usesrememberForever('totem.task.'.$id, ...)— this re-populates the exact cache key the tests assert was cleared.Whether the two queued listeners execute synchronously during
Event::dispatch()depends onconfig('queue.default'):testbenchCLI previously have a stalevendor/orchestra/testbench-core/laravel/.envsettingQUEUE_CONNECTION=database. The queued listeners get pushed to a DB queue and never execute during the test — onlyBustCacheImmediatelyfires, cache stays empty, assertion passes..envfile at that path (testbench ships only.env.example), soenv('QUEUE_CONNECTION', 'sync')falls back tosync.BuildCacheruns synchronously during dispatch and repopulatestotem.task.{id}before the assertion. Test fails.The test
test_bust_cache_clears_from_configured_storepasses in both environments becauseDeleting::dispatchonly wiresBustCacheImmediately— noBuildCacheto repopulate.Fix
Add
Queue::fake()to the three affected tests. The fake swaps Laravel's queue manager with a no-op recorder, so queued listeners get recorded and dropped instead of executed synchronously.BustCacheImmediately(not queued) still runs and clears the cache — matching the tests' evident intent of "only the immediate listener should matter here."(Same two-line addition in each of the three tests.)
Why this fix and not an alternative
\$this->loadEnvironmentVariables = trueinTestCase.php: masks this class of queue-timing dependency across the entire suite, bigger surface-area change.TotemEventServiceProvider: changes runtime behavior (production would lose the background cache-warming).QUEUE_CONNECTIONingetEnvironmentSetUp: same over-broad scope; the problem is specific to these three tests' assumption that "only sync listeners matter."Verification
Local reproduction of CI:
Both scenarios verified locally with this fix applied.
Test plan
CacheStoreTesttests pass locally with the stale vendor.envpresent.CacheStoreTesttests pass locally with the vendor.envremoved (CI condition).Release plan
No tag. No CHANGELOG entry (this is a test-only fix — no user-facing behavior change). Companion to PR #415 (v12.0.2 popup hotfix) which was blocked by this pre-existing CI issue.
Sequencing note
PR #415 (hotfix/empty-output-popup) will rebase onto this fix once merged, so its CI run exercises the fixed test harness.