fail() public method

public fail ( mixed $other, string $description, boolean $not = FALSE )
$other mixed The value passed to evaluate() which failed the constraint check.
$description string A string with extra description of what was going on while the evaluation failed.
$not boolean Flag to indicate negation.
Ejemplo n.º 1
0
 public function testFailureIsIdentical2()
 {
     $a = new stdClass();
     $b = new stdClass();
     $constraint = new PHPUnit_Framework_Constraint_IsIdentical($a);
     try {
         $constraint->fail($b, 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that two variables reference the same object.\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
         return;
     }
     $this->fail();
 }
Ejemplo n.º 2
0
 public function testConstraintIsIdentical2()
 {
     $a = new stdClass();
     $b = new stdClass();
     $constraint = new PHPUnit_Framework_Constraint_IsIdentical($a);
     try {
         $constraint->fail($b, 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that \nstdClass Object\n(\n)\n is identical to \nstdClass Object\n(\n)\n.", $e->getDescription());
         return;
     }
     $this->fail();
 }
Ejemplo n.º 3
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();
 }