Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Allow assertion of multiple JSON validation errors. #39568

Merged
merged 3 commits into from
Nov 11, 2021

Conversation

marshall-davis
Copy link
Contributor

Allow multiple validation error messages to be expected when testing responses from JSON API.

The TestResponse::assertJsonValidationErrors() method already accepts a single message to be expected for any given request attribute. It seems intuitive that since the actual JSON response might contain an array of validation errors, if more than one rule is violated, that this method could expect multiple messages per attribute.

Currently this assumes that each attribute will expect a single message and if an array is provided it will throw an exception for an array to string conversion when creating the error message.

The change allows for multiple messages to be expected and for the assertion to fail if any of the provided messages is not in the response.

All previous tests continue to pass and previous usages of this method still work so this should not break any existing code based on this method.

 Allow multiple validation error messages to be expected when
testing responses from JSON API.
 Remove extra blank line between paramters and return annotation.
@taylorotwell taylorotwell merged commit 8228b9a into laravel:8.x Nov 11, 2021
@taylorotwell
Copy link
Member

Thanks for contributing to Laravel! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants