PHPUnit_Framework_Assert::assertArrayNotHasKey PHP Method

assertArrayNotHasKey() public static method

Asserts that an array does not have a specified key.
public static assertArrayNotHasKey ( mixed $key, array | ArrayAccess $array, string $message = '' )
$key mixed
$array array | ArrayAccess
$message string
    public static function assertArrayNotHasKey($key, $array, $message = '')
    {
        if (!(is_integer($key) || is_string($key))) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer or string');
        }
        if (!(is_array($array) || $array instanceof ArrayAccess)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array or ArrayAccess');
        }
        $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_ArrayHasKey($key));
        static::assertThat($array, $constraint, $message);
    }

Usage Example

Example #1
0
 /**
  * Assert that the response view is missing a piece of bound data.
  *
  * @param  string  $key
  * @return void
  */
 public function assertViewMissing($key)
 {
     if (!isset($this->response->original) || !$this->response->original instanceof View) {
         return PHPUnit::assertTrue(false, 'The response was not a view.');
     }
     PHPUnit::assertArrayNotHasKey($key, $this->response->original->getData());
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertArrayNotHasKey
PHPUnit_Framework_Assert