assertArrayHasKey()
assertArrayHasKey(mixed $key, array $array[, string $message = ''])
Reports an error identified by $message if $array does not have the $key.
assertArrayNotHasKey() is the inverse of this assertion and takes the same arguments.
Example A.1: Usage of assertArrayHasKey()
<?php
use PHPUnit\Framework\TestCase;
class ArrayHasKeyTest extends TestCase
{
public function testFailure()
{
$this->assertArrayHasKey('foo', ['bar' => 'baz']);
}
}
?>
phpun