123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- use \PHPUnit_Framework_Constraint;
- use \PHPUnit_Framework_ExpectationFailedException;
- class ArrayHasSameValuesConstraint extends PHPUnit_Framework_Constraint
- {
- protected $array;
-
- public function __construct($array)
- {
- $this->array = $array;
- }
-
- public function evaluate($other, $description = '', $returnResult = FALSE)
- {
- $description = $description ?: 'Failed asserting that two arrays have the same elements.';
- if (count($this->array) !== count($other)) {
- throw new PHPUnit_Framework_ExpectationFailedException($description);
- }
- if (array_diff($this->array, $other)) {
- throw new PHPUnit_Framework_ExpectationFailedException($description);
- }
- return true;
- }
-
- public function toString()
- {
- return 'two arrays have the same elements.';
- }
- }
|