lithium\test\Unit::assertArrayHasKey()
Assert that the result array has given key.
$this->assertArrayHasKey('bar', ['bar' => 'baz']); // succeeds
$this->assertArrayHasKey('foo', ['bar' => 'baz']); // fails
Parameters
-
mixed
$expected
-
array
$array
-
string|boolean
$message
Returns
booleantrue
if the assertion succeeded, false
otherwise.
Source
public function assertArrayHasKey($key, $array, $message = '{:message}') {
if (is_object($array) && $array instanceof \ArrayAccess) {
$result = isset($array[$key]);
} else {
$result = array_key_exists($key, $array);
}
return $this->assert($result, $message, [
'expected' => $key,
'result' => $array
]);
}