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] Add unprocessable test response assertion #38553

Merged
merged 1 commit into from
Aug 26, 2021
Merged

[8.x] Add unprocessable test response assertion #38553

merged 1 commit into from
Aug 26, 2021

Conversation

jobyh
Copy link
Contributor

@jobyh jobyh commented Aug 26, 2021

  • Add assertUnprocessable method
  • Add test

Proposes a new ->assertUnprocessable() method on TestResponse to compliment the existing descriptive convenience methods.

I use ->assertOk(), ->assertUnauthorized(), ->assertForbidden() & friends in tests because they read really clearly and benefit from showing up in my editor's tab autocomplete so there's a small quality of life enhancement.

Working on a complex project with a lot of validation I've been wishing there was an equivalent for ->assertStatus(422) or the more human but long winded ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY).

The addition is syntactic sugar and does not modify any existing methods so there are no breaking changes.

* Add assertUnprocessable method
* Add test
@taylorotwell taylorotwell merged commit 21d2fb2 into laravel:8.x Aug 26, 2021
timmartin19 added a commit to timmartin19/framework that referenced this pull request Sep 1, 2021
Inspired by PR laravel#38553.  A readability enhancement in the same manner.
Just like `assertOk`, `assertUnauthorized` and company this adds an
`assertBadRequest` to ensure that a [400 Bad Request](https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1) was sent
in the response.

The intention is to increase readability and add broader support to the
existing suite of response code assertions which are much easier to
understand.

This introduces no breaking changes since it does not modify any
existing methods.

Also introduced a test case for the assert error path and the path where
there is no assertion error.
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
* Add assertUnprocessable method
* Add test

Co-authored-by: Joby Harding <[email protected]>
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