mirror of
https://github.com/predis/predis.git
synced 2026-08-28 03:02:04 +00:00
[tests] Improve the basic framework of our test suite.
We now have a base test case class for Predis (namely PredisTestCase) grouping various commonly used utility methods shared by all of the tests in the suite, greatly improving reusability. NOTE: Backported from v0.9-dev.
This commit is contained in:
@@ -9,9 +9,6 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use \PHPUnit_Framework_Constraint;
|
||||
use \PHPUnit_Framework_ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Constraint that accepts arrays with the same elements but different order.
|
||||
*/
|
||||
@@ -30,15 +27,14 @@ class ArrayHasSameValuesConstraint extends PHPUnit_Framework_Constraint
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function evaluate($other, $description = '', $returnResult = FALSE)
|
||||
public function matches($other)
|
||||
{
|
||||
$description = $description ?: 'Failed asserting that two arrays have the same elements.';
|
||||
|
||||
if (count($this->array) !== count($other)) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException($description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (array_diff($this->array, $other)) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException($description);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -49,6 +45,14 @@ class ArrayHasSameValuesConstraint extends PHPUnit_Framework_Constraint
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'two arrays have the same elements.';
|
||||
return 'two arrays contain the same elements.';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($other)
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user