Repository navigation
feat!: add active and inactive methods to unit of work port - #43
Merged
Merged
Conversation
Adds active() and inactive() to the UnitOfWork driven port, so callers can determine whether a unit of work is currently in progress. The FakeUnitOfWork implements both and now throws if execute() is called while it is already active. BREAKING CHANGE: implementations of the UnitOfWork interface must add the active() and inactive() methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Adds
active()andinactive()to theUnitOfWorkdriven port, so callers can tell whether a unit of work is in progress. This is a breaking change. Every implementation of the interface must add both methods, so this PR targetsnext(7.x).Changes
Contracts\Application\Ports\UnitOfWork: newactive()andinactive()methods, with docblocks.Testing\FakeUnitOfWork:execute()callback runs, including on each retry, and inactive before and after, whether the callback committed, rolled back or threw.RuntimeExceptionifexecute()is called while it is already active. This matchesUnitOfWorkManager, which does not support nested units of work.units-of-work.md: the interface listing and the Laravel adapter example now include the new methods, and the Testing section describes the fake's behaviour.upgrade.md: new6.x to 7.xsection.CHANGELOG.md: newUnreleased Next Majorheading aboveUnreleased, with a BREAKING entry.CLAUDE.md: new guidance on breaking changes. They must targetnext, and onnexttheir changelog entries go underUnreleased Next Major.Note for reviewers
In the Laravel example,
active()usestransactionLevel() > 0. That counts every open transaction on the connection, including ones not started through the adapter'sexecute(), such as the transactionRefreshDatabasewraps around each test.Test plan
composer allpasses (deptrac, phpstan, pint, phpunit)🤖 Generated with Claude Code