[2.x] fix(testing): Run after-commit callbacks inline in integration tests - #4833
Merged
Conversation
Binding db.transactions (#4787) means listeners implementing ShouldHandleEventsAfterCommit are deferred to the surrounding transaction's commit. The integration harness wraps each test in a transaction that is rolled back and never committed, so those callbacks were attached to it and silently discarded — after-commit behaviour could not be tested (#4814). Bind a DatabaseTransactionsManager subclass in the test harness that reports no applicable pending transactions, so addCallback() runs each callback immediately. db.transactions stays bound and Connection::afterCommit() still works, keeping #4787 intact. Refs #4814
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.
Fixes #4814.
Binding
db.transactions(#4787) means listeners implementingShouldHandleEventsAfterCommit— and events implementingShouldDispatchAfterCommit, and any directConnection::afterCommit()callback — are deferred to the surrounding transaction's commit. The integration harness wraps each test in a transaction that is rolled back and never committed, so those callbacks were attached to it and silently discarded. After-commit behaviour therefore could not be observed or asserted in integration tests, with no error.The test harness now binds a
DatabaseTransactionsManagersubclass (InlineTransactionsManager) that reports no applicable pending transactions, soaddCallback()runs each callback immediately instead of deferring it.db.transactionsstays bound and attached to the connection, soConnection::afterCommit()still works and #4787 stays intact —AfterCommitTestcontinues to pass.The manager is bound and attached to the connection via a
BindInlineTransactionsManagerextender that runs before the harness opens its transaction.Covered by integration tests for all three paths: a direct
afterCommit()callback, aShouldHandleEventsAfterCommitlistener, and aShouldDispatchAfterCommitevent.