public static function PHPUnit_Framework_Assert::assertArrayHasKey

Asserts that an array has a specified key.

@since Method available since Release 3.0.0

Parameters

mixed $key:

array|ArrayAccess $array:

string $message:

6 calls to PHPUnit_Framework_Assert::assertArrayHasKey()
Framework_AssertTest::testAssertArrayHasIntegerKey in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey
Framework_AssertTest::testAssertArrayHasKeyAcceptsArrayAccessValue in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey
Framework_AssertTest::testAssertArrayHasKeyProperlyFailsWithArrayAccessValue in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey @expectedException PHPUnit_Framework_AssertionFailedError
Framework_AssertTest::testAssertArrayHasKeyThrowsException in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertArrayHasStringKey in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey

... See full list

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php, line 72

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertArrayHasKey($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_ArrayHasKey($key);
  self::assertThat($array, $constraint, $message);
}