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] Fix display of validation errors occurred when asserting status #38088

Merged
merged 6 commits into from
Jul 21, 2021
Merged

[8.x] Fix display of validation errors occurred when asserting status #38088

merged 6 commits into from
Jul 21, 2021

Conversation

jessarcher
Copy link
Member

As discovered by @paulredmond, the display of unexpected validation errors introduced in #38046 doesn't actually work in practice because a ValidationException is not reported by the exception handler. Paul's diagnosis can be found here. Thankfully this doesn't actually break any existing behaviour.

This PR fixes the issue by also showing errors from a redirect response with session errors (i.e. a non-JSON validation response) and errors in JSON response content, instead of only looking at reported exceptions.

I have learned my lesson and tested this in a new laravel/laravel project.

Errors in redirect response session:

image

Errors in response JSON content:

image

The behaviour is slightly different than before because assertStatus() no longer only displays errors for unexpected 500 and 422 responses, and instead just displays any reported exceptions, session errors, or JSON errors when the status is not as asserted. This also makes assertStatus() behave the same as assertSuccessful().

I also took the opportunity to standardise the messaging of "Expected response status code" which in some instances was just "Expected status code".

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.

2 participants