You are here

public static function PHPUnit_Framework_Assert::assertArrayHasKey in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Assert.php \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:

9 calls to PHPUnit_Framework_Assert::assertArrayHasKey()
Framework_AssertTest::testAssertArrayHasIntegerKey in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey
Framework_AssertTest::testAssertArrayHasKeyAcceptsArrayAccessValue in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey
Framework_AssertTest::testAssertArrayHasKeyAcceptsArrayObjectValue in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey
Framework_AssertTest::testAssertArrayHasKeyProperlyFailsWithArrayAccessValue in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey @expectedException PHPUnit_Framework_AssertionFailedError
Framework_AssertTest::testAssertArrayHasKeyProperlyFailsWithArrayObjectValue in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertArrayHasKey @expectedException PHPUnit_Framework_AssertionFailedError

... See full list

File

vendor/phpunit/phpunit/src/Framework/Assert.php, line 31

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);
}