lithium\test\Unit::assertArrayNotHasKey()

public method

Assert that the result array does not have given key.

$this->assertArrayNotHasKey('foo', ['bar' => 'baz']); // succeeds
$this->assertArrayNotHasKey('bar', ['bar' => 'baz']); // fails

Parameters

  • mixed $expected
  • array $array
  • string|boolean $message

Returns

boolean

true if the assertion succeeded, false otherwise.

Source

	public function assertArrayNotHasKey($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
		]);
	}