Exemplo n.º 1
0
 /**
  * @param  PHPUnit_Framework_MockObject_Invocation $invocation
  * @return boolean
  */
 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->getDescription()), $e->getComparisonFailure());
     }
     return TRUE;
 }