PHPUnit_Framework_Constraint_ArraySubset
class PHPUnit_Framework_Constraint_ArraySubset extends PHPUnit_Framework_Constraint (View source)
Constraint that asserts that the array it is evaluated for has a specified subset.
Uses array_replace_recursive() to check if a key value subset is part of the subject array.
Properties
protected | $exporter | from PHPUnit_Framework_Constraint | |
protected array|Traversable | $subset | ||
protected bool | $strict |
Methods
Evaluates the constraint for parameter $other
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
Throws an exception for the given compared value and test description
Return additional failure description where needed
Returns the description of the failure
Returns a string representation of the constraint.
Details
at line 33
__construct(array|Traversable $subset, bool $strict = false)
mixed
evaluate(mixed $other, string $description = '', bool $returnResult = false)
Evaluates the constraint for parameter $other
If $returnResult is set to false (the default), an exception is thrown in case of a failure. null is returned otherwise.
If $returnResult is true, the result of the evaluation is returned as a boolean value instead: true in case of success, false in case of a failure.
at line 48
protected bool
matches(mixed $other)
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
int
count()
Counts the number of constraint elements.
protected
fail(mixed $other, string $description, ComparisonFailure $comparisonFailure = null)
Throws an exception for the given compared value and test description
protected string
additionalFailureDescription(mixed $other)
Return additional failure description where needed
The function can be overridden to provide additional failure information like a diff
at line 84
protected string
failureDescription(mixed $other)
Returns the description of the failure
The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second part of that sentence.
at line 69
string
toString()
Returns a string representation of the constraint.