예제 #1
0
파일: Matcher.php 프로젝트: rmehner/phpunit
 /**
  * @throws PHPUnit_Framework_Exception
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function verify()
 {
     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');
     }
     try {
         $this->invocationMatcher->verify();
         if ($this->parametersMatcher !== NULL) {
             $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->getDescription()));
     }
 }
예제 #2
0
 /**
  * @throws PHPUnit_Framework_Exception
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function verify()
 {
     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');
     }
     try {
         $this->invocationMatcher->verify();
         $invocationIsAny = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount';
         if ($this->parametersMatcher !== NULL and !$invocationIsAny) {
             $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()));
     }
 }
예제 #3
0
 /**
  * @throws PHPUnit_Framework_Exception
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function verify()
 {
     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');
     }
     try {
         $this->invocationMatcher->verify();
         if ($this->parametersMatcher === null) {
             $this->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters();
         }
         $invocationIsAny = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount';
         $invocationIsNever = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_InvokedCount' && $this->invocationMatcher->isNever();
         if (!$invocationIsAny && !$invocationIsNever) {
             $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(), PHPUnit_Framework_TestFailure::exceptionToString($e)));
     }
 }
예제 #4
0
 /**
  * @param \PHPUnit_Framework_MockObject_Invocation $invocation
  */
 public function validate(\PHPUnit_Framework_MockObject_Invocation $invocation)
 {
     if ($this->parameters) {
         $this->parameters->matches($invocation);
     }
 }