feat(test-writing): forbid DB mutation in migration setUp/tearDown#111
Merged
Martin Bens (SpiGAndromeda) merged 1 commit intoMay 13, 2026
Merged
Conversation
Migration test classes always contain testGetCreationTimestamp (MIGRATION-008), which runs the same setUp and tearDown but never touches the database. Mutations placed in those hooks therefore run around a test that doesn't need them and leave non-transactional schema or per-row state for sibling test classes. shopware/shopware PR #16799 fixed this pattern across 19 files. MIGRATION-009 catches it on the way in. The rule flags ALTER, CREATE, DROP, INSERT, UPDATE, DELETE, TRUNCATE, REPLACE plus $conn->insert/update/delete and schema-manager mutations inside setUp or tearDown, including inside try/catch wrappers. Connection acquisition, PHP-side ID generation, and read-only fetches stay permitted. Two canonical fixes work: a private helper called from the test method, or a try/finally block inside the test. MIGRATION-005 was broadened in the same change. Its "in setUp/tearDown" qualifier is gone now that MIGRATION-009 owns where cleanup lives. The one-statement-per-try and catch-Throwable teaching points still apply at any cleanup site. The Schema-Remove section of the migration test template no longer restores via tearDown. Restore now lives inside testUpdateDestructive in a try/finally block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Agent Skills ExportBuilt 6 skill packages: |
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.
No description provided.