public function PHPUnit_Framework_MockObject_Matcher::matches in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php \PHPUnit_Framework_MockObject_Matcher::matches()
Parameters
PHPUnit_Framework_MockObject_Invocation $invocation:
Return value
bool
Overrides PHPUnit_Framework_MockObject_Matcher_Invocation::matches
File
- vendor/
phpunit/ phpunit-mock-objects/ src/ Framework/ MockObject/ Matcher.php, line 159
Class
- PHPUnit_Framework_MockObject_Matcher
- Main matcher which defines a full expectation using method, parameter and invocation matchers. This matcher encapsulates all the other matchers and allows the builder to set the specific matchers when the appropriate methods are called…
Code
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) {
if ($this->afterMatchBuilderId !== null) {
$builder = $invocation->object
->__phpunit_getInvocationMocker()
->lookupId($this->afterMatchBuilderId);
if (!$builder) {
throw new PHPUnit_Framework_Exception(sprintf('No builder found for match builder identification <%s>', $this->afterMatchBuilderId));
}
$matcher = $builder
->getMatcher();
if (!$matcher) {
return false;
}
if (!$matcher->invocationMatcher
->hasBeenInvoked()) {
return false;
}
}
if ($this->invocationMatcher === null) {
throw new PHPUnit_Framework_Exception('No invocation matcher is set');
}
if ($this->methodNameMatcher === null) {
throw new PHPUnit_Framework_Exception('No method matcher is set');
}
if (!$this->invocationMatcher
->matches($invocation)) {
return false;
}
try {
if (!$this->methodNameMatcher
->matches($invocation)) {
return false;
}
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
throw new PHPUnit_Framework_ExpectationFailedException(sprintf("Expectation failed for %s when %s\n%s", $this->methodNameMatcher
->toString(), $this->invocationMatcher
->toString(), $e
->getMessage()), $e
->getComparisonFailure());
}
return true;
}