public function match($value, $pattern)
{
if (parent::match($value, $pattern)) {
return true;
}
if (!is_array($value)) {
$this->error = sprintf("%s \"%s\" is not a valid array.", gettype($value), new StringConverter($value));
return false;
}
if ($this->isArrayPattern($pattern)) {
return $this->allExpandersMatch($value, $pattern);
}
if (false === $this->iterateMatch($value, $pattern)) {
return false;
}
return true;
}
public function test_error_description_when_any_matcher_can_match() { $this->firstMatcher->expects($this->once())->method('canMatch')->will($this->returnValue(false)); $this->secondMatcher->expects($this->once())->method('canMatch')->will($this->returnValue(false)); $this->assertEquals($this->matcher->match('foo', 'foo_pattern'), false); $this->assertEquals($this->matcher->getError(), 'Any matcher from chain can\'t match value "foo" to pattern "foo_pattern"'); }