Laravel - HTTP Tests - Assert View Has

Assert that the response view contains given a piece of data:

    $response->assertViewHas($key, $value = null);

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:

    $response->assertViewHas('user', function (User $user) {
        return $user->name === 'Taylor';

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

    $this->assertEquals('Taylor', $response['name']);