public function PHPUnit_Framework_MockObject_Matcher::invoked

Parameters

PHPUnit_Framework_MockObject_Invocation $invocation:

Return value

mixed

Overrides PHPUnit_Framework_MockObject_Matcher_Invocation::invoked

File

drupal/core/vendor/phpunit/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher.php, line 136

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 invoked(PHPUnit_Framework_MockObject_Invocation $invocation) {
  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->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 && $matcher->invocationMatcher
      ->hasBeenInvoked()) {
      $this->afterMatchBuilderIsInvoked = TRUE;
    }
  }
  $this->invocationMatcher
    ->invoked($invocation);
  try {
    if ($this->parametersMatcher !== NULL && !$this->parametersMatcher
      ->matches($invocation)) {
      $this->parametersMatcher
        ->verify();
    }
  } 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());
  }
  if ($this->stub) {
    return $this->stub
      ->invoke($invocation);
  }
  return NULL;
}