[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.
This commit is contained in:
Daniele Alessandri
2013-11-30 18:05:56 +01:00
parent 7f690cb62e
commit b253bdc41e
218 changed files with 411 additions and 754 deletions
+13 -6
View File
@@ -27,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;
@@ -46,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();
}
}