[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:
Daniele Alessandri
2013-12-01 14:10:25 +01:00
parent e4e2238f34
commit a9b42924e5
224 changed files with 831 additions and 890 deletions
+14 -10
View File
@@ -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();
}
}