Laravel\Lumen\Testing\AssertionsTrait::assertViewHas PHP Method

assertViewHas() public method

Assert that the response view has a given piece of bound data.
public assertViewHas ( string | array $key, mixed $value = null ) : void
$key string | array
$value mixed
return void
    public function assertViewHas($key, $value = null)
    {
        if (is_array($key)) {
            return $this->assertViewHasAll($key);
        }
        if (!isset($this->response->original) || !$this->response->original instanceof View) {
            return PHPUnit::assertTrue(false, 'The response was not a view.');
        }
        if (is_null($value)) {
            PHPUnit::assertArrayHasKey($key, $this->response->original->getData());
        } else {
            PHPUnit::assertEquals($value, $this->response->original->{$key});
        }
    }