evaluate() public method

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.
return boolean
 /**
  * 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();
 }