Skip to content

[12.x] Add assertClientError method to TestResponse #55750

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

Merged
merged 1 commit into from
May 16, 2025

Conversation

shane-zeng
Copy link
Contributor

This PR adds the assertClientError to the TestResponse class.

It provides a convenient way to assert that the response status code is in the 4xx range, improving test readability when the specific client error code is not important.

This will allow to use:

$response->assertClientError();

instead of:

$this->assertTrue($response->isClientError());

This aligns with other expressive methods like assertServerError() and makes tests more readable and intention-revealing.

@taylorotwell taylorotwell merged commit fba3b98 into laravel:12.x May 16, 2025
61 checks passed
@shane-zeng shane-zeng deleted the assert-client-error branch May 17, 2025 02:09
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