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