#4488 Make the three diagnostics tests assert over their own data instead of the whole schema - #4508
#4488 Make the three diagnostics tests assert over their own data instead of the whole schema#4508keystone-guru-bot wants to merge 2 commits into
Conversation
|
🤖 Cold review (codex) @ ff64e4e: The isolation improvements remove an existing behavior check without equivalent replacement coverage. Tests could not be run because Docker access is blocked by the sandbox. Review comment:
|
|
🤖 The Restored in two places, both database-independent as suggested:
The reconciliation test now measures the counts as deltas against a baseline taken after the link exists but before it holds any benefit row — a link with no benefits is not a holder, so the baseline is the rest of the schema with everything else about the test already in place. It asserts Re-verified with a stray benefit-holding link present in the phpunit schema: 21 passed. No changes needed on points 2–4. |
ed1c2d9 to
f72cab1
Compare
…tead of the whole schema Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017gFvTB77bu1QKhL1U9Y48m
…econciliation counts as deltas Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017gFvTB77bu1QKhL1U9Y48m
f72cab1 to
9148f9e
Compare
🤖 Closes #4488
Scoped to three of the five tests: the
SpellTuningSnapshotLoaderTestpair is #4501's, which was already in progress when this started. Agreed with Wotuu up front rather than closing #4501 as a duplicate.The premise changed, but the defect is real
The three tests in scope already pass on
masterwith an isolated cache and a freshly provisioned schema — #4489 (#4481) and #4490 (#4485) landed after #4488 was filed. Verified with the issue's own command, plus a plain run and two consecutive runs, all green before touching anything.So the first half of the definition of done was already met. The second half — "each test creates or seeds the state it depends on rather than inheriting it" — was not, and that is what this PR does. The failures were never cache effects: all three read schema-wide and assert on absolute counts or list positions, so a single foreign row decides the outcome.
Reproduced both reported symptoms from one stray row
Inserting one benefit-holding
PatreonUserLinkinto the phpunit schema reproduces both symptoms the issue reported, exactly:Failed asserting that true is falsePatreonDiagnosticsServiceReconciliationTest:108Failed asserting that 8 is identical to 50Failed asserting that 97 is identical to 132APIPatreonDiagnosticsControllerTest:306Both numbers in the second are
patreon_user_links.idvalues, not counts. With the fixes applied and the same stray row still present, all three classes pass; with the fixes stashed, the two assertions fail again. That is the before/after evidence for this PR.What changed
PatreonDiagnosticsServiceReconciliationTestassertFalse($reconciliation->needsAttention())is computed over every benefit-holding link in the schema (PatreonDiagnosticsService.php:314-326), so the developer's own Patreon link — or one row leaked by an aborted earlier run — makes it true regardless of the test. Replaced with a scopedassertNoneOfThisTestsLinksAreReported(), which still catches the bug the original guarded (a matched link wrongly dumped into a reported bucket) without depending on the rest of the schema. This follows the principle the class's ownfindHolder()docblock already states; that one assertion was the exception to it.APIPatreonDiagnosticsControllerTestunmatched_holders.0.*→ located bypatreon_user_link_id. The list covers every benefit-holding link in no defined order, so any other such link owns index 0.data.0/data.1over sync runs → asserted over this class's own two runs. The endpoint returns every run in the schema, so any run recorded in the last two hours shifts every index.missed_by_latest_run→ its run'sstarted_atis now derived from the current maximum, so it wins "most recent" outright instead of relying onsubMinutes(5)beating whatever else exists.tearDown()ranPatreonSyncRun::query()->delete(), wiping every sync-run row in the schema, not just its own. That both masked pollution for its own later tests and destroyed rows belonging to anything else. Now scoped to the ids it created — verified a foreign run survives a full class run.AdminToolsCombatLogControllerTest(%d) — 1 ⚠ …) is a count over every failure row for that (dungeon, mapping version, npc), not the one row the test creates. Now read before the insert and asserted asbefore + 1.setUp()flushes thetmp_filecache store.MapContextMappingVersionDatamemoises the enemy/floor payload throughRemembersToFile, a file cache with a 24h TTL thatphpunit.xmlredirects to/tmp/phpunit_cachebut never clears — so the rendered map could come from a previous run's mapping data. This is the one cache these tests genuinely inherited, and the oneCACHE_STORE=arraydoes not cover.Doing this systemically in
TestCase::setUp()instead would be the stronger fix, but it flushes on every one of ~3,170 tests and would surface unrelated failures; worth its own issue if wanted.Verification
--group=Patreon— 79 passed.--group=Controller— 753 passed.composer run analyse— no errors.composer run fix— no changes.🤖 Generated with Claude Code
https://claude.ai/code/session_017gFvTB77bu1QKhL1U9Y48m