\PHPUnit_Framework_Constraint_ArrayHasKey

Constraint that asserts that the array it is evaluated for has a given key.

Uses array_key_exists() to check if the key is found in the input array, if
not found the evaluation fails.

The array key is passed in the constructor.

Synopsis

class PHPUnit_Framework_Constraint_ArrayHasKey extends PHPUnit_Framework_Constraint {
  • // members
  • protected integer|string $key;
  • // Inherited members from PHPUnit_Framework_Constraint
  • protected $exporter;
}

Hierarchy

Violations

Checkstyle

Line Column Severity Message
64 1 error Each class must be in a namespace of at least one level (a top-level vendor name)
64 1 error Class name "PHPUnit_Framework_Constraint_ArrayHasKey" is not in camel caps format

Members

protected

Methods

protected

  • failureDescription() — Returns the description of the failure
  • matches() — Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

public

Inherited from PHPUnit_Framework_Constraint

protected

  • additionalFailureDescription() — Return additional failure description where needed
  • fail() — Throws an exception for the given compared value and test description
  • failureDescription() — Returns the description of the failure
  • matches() — Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

public

  • count() — Counts the number of constraint elements.
  • evaluate() — Evaluates the constraint for parameter $other

History