Skip to content

Commit 518b8cd

Browse files
[10.x] Add assertThrows in http tests (#8795)
* add `assertThrows` into http-tests * remove $response * Update http-tests.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent aa4f1cf commit 518b8cd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

http-tests.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ In addition, if you would like to ensure that your application is not utilizing
238238

239239
$response = $this->withoutDeprecationHandling()->get('/');
240240

241+
The `assertThrows` method may be used to assert that code within a given closure throws an exception of the specified type:
242+
243+
```php
244+
$this->assertThrows(
245+
fn () => (new ProcessOrder)->execute(),
246+
OrderInvalid::class
247+
);
248+
```
249+
241250
<a name="testing-json-apis"></a>
242251
## Testing JSON APIs
243252

0 commit comments

Comments
 (0)