public function match($value)
{
if (!is_array($value)) {
$this->error = sprintf("Count expander require \"array\", got \"%s\".", new StringConverter($value));
return false;
}
if (count($value) !== $this->value) {
$this->error = sprintf("Expected count of %s is %s.", new StringConverter($value), new StringConverter($this->value));
return false;
}
return true;
}
/** * @dataProvider invalidCasesProvider */ public function test_error_when_matching_fail($boundary, $value, $errorMessage) { $expander = new Count($boundary); $this->assertFalse($expander->match($value)); $this->assertEquals($errorMessage, $expander->getError()); }