! change: Refactor nested WasCalled assertions#29
Merged
Conversation
WasCalled assertion wrappersWasCalled assertions
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.
Warning
This PR contains a breaking change. See upgrade guide for more details.
Context
In an attempt not to overload the
WasCalledconstraint with more methods, this PR aims to simplify its API by abstracting thewithSame()method onto a standalone assertionCraftzing\TestBench\PHPUnit\Constraint\Callables\Assertions\WithSameArguments. This allows us to add moreWasCalledassertions likeCraftzing\TestBench\PHPUnit\Constraint\Callables\Assertions\WithEqualArguments(as introduced in this PR.Failure output improvements
Previously, whenever a
WasCalledassertion failed, PHPUnit would export the full object in the failure description. E.g.:Even with really simply arguments like short strings, this output was already very verbose. And it only gets worse when passing objects as arguments.
Therefore, this PR proposes to simplify the object representation to:
Upgrade guide
Craftzing\TestBench\PHPUnit\Constraint\Callables\WasCalled::withSame()is no longer available. You can replace it by providing the newCraftzing\TestBench\PHPUnit\Constraint\Callables\Assertions\WithSameArgumentsassertion as first argument toWasCalled:You may now also use loose comparison: