PHPUnit_Framework_Constraint_Not::fail PHP Method

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.
    public function fail($other, $description, $not = FALSE)
    {
        if (count($this->constraint) == 1 || $this->constraint instanceof PHPUnit_Framework_Constraint_Attribute) {
            $this->constraint->fail($other, $description, TRUE);
        } else {
            parent::fail($other, $description, !$not);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function testFailureTraversableNotContains2()
 {
     $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_TraversableContains('foo'));
     try {
         $constraint->fail(array('foo'), 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that an array does not contain <string:foo>.\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
         return;
     }
     $this->fail();
 }
All Usage Examples Of PHPUnit_Framework_Constraint_Not::fail