Skip to content

Commit e37def3

Browse files
document that assertViewHas also accepts a closure (#7210)
* document that assertViewHas also accepts a closure * Update http-tests.md Co-authored-by: Taylor Otwell <[email protected]>
1 parent 0d15bbe commit e37def3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

http-tests.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,12 @@ Assert that the response has an unauthorized (401) HTTP status code:
995995
Assert that the response view contains given a piece of data:
996996

997997
$response->assertViewHas($key, $value = null);
998+
999+
Passing a closure as the second argument to the `assertViewHas` method will allow you to inspect and make assertions against a particular piece of view data:
1000+
1001+
$response->assertViewHas('user', function (User $user) {
1002+
return $user->name === 'Taylor';
1003+
});
9981004

9991005
In addition, view data may be accessed as array variables on the response, allowing you to convenient inspect it:
10001006

0 commit comments

Comments
 (0)