PHPUnit_Framework_Constraint::evaluate PHP Method

evaluate() public method

If $returnResult is set to false (the default), an exception is thrown in case of a failure. null is returned otherwise. If $returnResult is true, the result of the evaluation is returned as a boolean value instead: true in case of success, false in case of a failure.
public evaluate ( mixed $other, string $description = '', boolean $returnResult = false ) : mixed
$other mixed Value or object to evaluate.
$description string Additional information about the test
$returnResult boolean Whether to return a result or throw an exception
return mixed
    public function evaluate($other, $description = '', $returnResult = false)
    {
        $success = false;
        if ($this->matches($other)) {
            $success = true;
        }
        if ($returnResult) {
            return $success;
        }
        if (!$success) {
            $this->fail($other, $description);
        }
    }

Usage Example

 protected function matches($other)
 {
     if (!$other instanceof ResponseInterface) {
         return false;
     }
     return $this->status->evaluate($other->getStatusCode(), '', true);
 }
All Usage Examples Of PHPUnit_Framework_Constraint::evaluate