public function assertMismatchDescription($expected, Hamcrest_Matcher $matcher, $arg)
 {
     $description = new Hamcrest_StringDescription();
     $this->assertFalse($matcher->matches($arg), 'Precondtion: Matcher should not match item');
     $matcher->describeMismatch($arg, $description);
     $this->assertEquals($expected, (string) $description, 'Expected mismatch description');
 }
예제 #2
0
 /**
  * Performs the actual assertion logic.
  *
  * If <code>$matcher</code> doesn't match <code>$actual</code>,
  * throws a {@link Hamcrest_AssertionError} with a description
  * of the failure along with the optional <code>$identifier</code>.
  *
  * @param string $identifier added to the message upon failure
  * @param mixed $actual value to compare against <code>$matcher</code>
  * @param Hamcrest_Matcher $matcher applied to <code>$actual</code>
  */
 private static function doAssert($identifier, $actual, Hamcrest_Matcher $matcher)
 {
     if (!$matcher->matches($actual)) {
         $description = new Hamcrest_StringDescription();
         if (!empty($identifier)) {
             $description->appendText($identifier . PHP_EOL);
         }
         $description->appendText('Expected: ')->appendDescriptionOf($matcher)->appendText(PHP_EOL . '     but: ');
         $matcher->describeMismatch($actual, $description);
         throw new Hamcrest_AssertionError((string) $description);
     }
 }
예제 #3
0
 /**
  * Executes the matcher on a given argument value.
  *
  * Forwards the call to Hamcrest's matches() method.
  *
  * @param mixed $argument
  *
  * @return boolean
  */
 public function matches(&$argument)
 {
     return $this->matcher->matches($argument);
 }