Assert that a response matches the specified errors #41741
Unanswered
pacoorozco
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I'm testing my controller I usually create several test cases to ensure that validation is in place. I usually create a data provider with the form data and the errors that I'm expected. In order to assert if the validation has raised errors I was using
assertSessionHasErrors()
andassertSessionDoesNotHaveErrors()
.But I've created a new assertion that could be interesting to be shared:
assertSessionMatchesErrors()
.The assertion will pass if the provided errors and only these ones are present in the session.
Let's imagine a form request with 4 fields that are validated:
field1
,field2
,field3
andfield4
.If you have a testcase to ensure that
field1
validation fails you need to do:I've created this PR just in case that you can to take a look to my implementation.
Do you think it could be useful?
Beta Was this translation helpful? Give feedback.
All reactions