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

[11.x] Inspect exception of assertThrows #52224

Merged

Conversation

gdebrauwer
Copy link
Contributor

The assertThrows test method makes it possible to assert if a specific exception is thrown. You can also assert the message of the exception. But what if you want to assert other data/properties of the thrown exception? That is currently not possible, but this PR fixes that.

$this->assertThrows(
    fn () => throw new FooException(),
    fn (FooException $exception) => $exception->getBar() === 'baz'
);

@taylorotwell taylorotwell merged commit 1301d9c into laravel:11.x Jul 22, 2024
11 of 15 checks passed
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