[11.x] Restore exceptions/errors to test assertion failure messages #51725
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.
This PR is an alternative to #51709 that solves the issue of unexpected exceptions and validation errors no longer being included in test assertion failures.
#51709 only solves the issue for status assertions and only includes unexpected exceptions but not validation errors.
I couldn't find anything in PHPUnit that would let me hook in to catch and transform the exceptions globally like we used to, so I've removed the code we had there are localized the responsibility to the
TestResponse
class. I tried a few different ideas, like wrapping every assertion in atry/catch
or inside a closure that gets passed to another method that does the try/catch, but I ultimately felt it was nicer to wrap theAssert
class instead.I have removed some methods and properties that might constitute a BC; however, these were all contained within the testing side of the framework. I'm happy to re-instate them with a
@deprecated
tag if preferred.