evaluate() 공개 메소드

Evaluates the constraint for parameter $other. Returns TRUE if the constraint is met, FALSE otherwise.
public evaluate ( mixed $other ) : boolean
$other mixed Value or object to evaluate.
리턴 boolean
예제 #1
0
 /**
  * Asserts that one array is identical to another, but the order of keys does not matter.
  *
  * @param $expected
  * @param $actual
  */
 public static function assertSimilar($expected, $actual)
 {
     if (!is_array($expected) || !is_array($actual)) {
         throw new \PHPUnit_Framework_AssertionFailedError('Only arrays can be compared');
     }
     ksort($expected);
     ksort($actual);
     $constraint = new \PHPUnit_Framework_Constraint_IsIdentical($expected);
     $constraint->evaluate($actual);
 }
예제 #2
0
 public function testConstraintIsIdentical()
 {
     $a = new stdClass();
     $b = new stdClass();
     $constraint = new PHPUnit_Framework_Constraint_IsIdentical($a);
     $this->assertFalse($constraint->evaluate($b));
     $this->assertTrue($constraint->evaluate($a));
     $this->assertEquals("is identical to \nstdClass Object\n(\n)\n", $constraint->toString());
     try {
         $constraint->fail($b, '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("Failed asserting that \nstdClass Object\n(\n)\n is identical to \nstdClass Object\n(\n)\n.", $e->getDescription());
         return;
     }
     $this->fail();
 }