unittest\Output::assertion PHP Method

assertion() public method

Outputs an assertion result.
public assertion ( $test, string $assertion, array | null $args, null | boolean $result ) : void
$assertion string Name of the assertion
$args array | null Array of arguments used during test
$result null | boolean True-pass,False-fail,null-skipped
return void
    public function assertion($test, $assertion, $args, $result)
    {
        if ($result === true) {
            $type = self::SUCCESS;
        } elseif ($result === null) {
            $type = self::DEBUG;
        } else {
            $type = self::ERROR;
        }
        switch (VERBOSITY_LEVEL) {
            case 3:
                if ($result === true) {
                    $print = "Passed";
                } elseif ($result === null) {
                    $print = "Skipped";
                } else {
                    $print = "Failed";
                }
                $this->send(sprintf('%s - %s (%s) [%s]', $test->name, $assertion, $print, $this->variable($args)), $type);
                $this->send_linebreak();
                $this->send($this->get_assertion_call_line(), self::DEBUG);
                break;
            case 2:
                if ($result === true) {
                    $print = "Passed";
                } elseif ($result === null) {
                    $print = "Skipped";
                } else {
                    $print = "Failed";
                }
                $this->send(sprintf("%s - %s", $print, $assertion), $type, true);
                break;
            default:
            case 1:
                if ($this->_breakcount >= 60) {
                    $nl = true;
                    $this->_breakcount = -1;
                } else {
                    $nl = false;
                }
                if ($result === true) {
                    $print = ".";
                } elseif ($result === null) {
                    $print = "S";
                } else {
                    $print = "F";
                }
                $this->send($print, $type, $nl);
                $this->_breakcount++;
                break;
        }
    }