From abd55e6d0aaf3a74b7f1cfec320316e4ae3fa472 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Thu, 24 Aug 2023 12:25:21 -0300 Subject: [PATCH] adding throwsUnless --- exceptions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exceptions.md b/exceptions.md index 49fa9a6..d8d867b 100644 --- a/exceptions.md +++ b/exceptions.md @@ -37,6 +37,14 @@ it('throws exception', function () { })->throwsIf(fn() => DB::getDriverName() === 'mysql', Exception::class, 'MySQL is not supported.'); ``` +Just like `throwsIf()` method, you can use the `throwsUnless()` method to conditionally verify an exception if a given boolean expression evaluates to false. + +```php +it('throws exception', function () { + // +})->throwsUnless(fn() => DB::getDriverName() === 'mysql', Exception::class, 'Only MySQL is supported.'); +``` + You can also verify that a given closure throws one or more exceptions using the [toThrow()](/docs/expectations#expect-toThrow) method of the expectation API. ```php