Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SummaryPrinter.php

function SummaryPrinter::print

File

vendor/phpunit/phpunit/src/TextUI/Output/SummaryPrinter.php, line 34

Class

SummaryPrinter
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\TextUI\Output

Code

public function print(TestResult $result) : void {
    if ($result->numberOfTestsRun() === 0) {
        $this->printWithColor('fg-black, bg-yellow', 'No tests executed!');
        return;
    }
    if ($result->wasSuccessfulAndNoTestHasIssues() && !$result->hasTestSuiteSkippedEvents() && !$result->hasTestSkippedEvents()) {
        $this->printWithColor('fg-black, bg-green', sprintf('OK (%d test%s, %d assertion%s)', $result->numberOfTestsRun(), $result->numberOfTestsRun() === 1 ? '' : 's', $result->numberOfAssertions(), $result->numberOfAssertions() === 1 ? '' : 's'));
        $this->printNumberOfIssuesIgnoredByBaseline($result);
        return;
    }
    $color = 'fg-black, bg-yellow';
    if ($result->wasSuccessful()) {
        if (!$result->hasTestsWithIssues()) {
            $this->printWithColor($color, 'OK, but some tests were skipped!');
        }
        else {
            $this->printWithColor($color, 'OK, but there were issues!');
        }
    }
    else {
        if ($result->hasTestErroredEvents() || $result->hasTestTriggeredPhpunitErrorEvents()) {
            $color = 'fg-white, bg-red';
            $this->printWithColor($color, 'ERRORS!');
        }
        elseif ($result->hasTestFailedEvents()) {
            $color = 'fg-white, bg-red';
            $this->printWithColor($color, 'FAILURES!');
        }
        elseif ($result->hasWarnings()) {
            $this->printWithColor($color, 'WARNINGS!');
        }
        elseif ($result->hasDeprecations()) {
            $this->printWithColor($color, 'DEPRECATIONS!');
        }
        elseif ($result->hasNotices()) {
            $this->printWithColor($color, 'NOTICES!');
        }
    }
    $this->printCountString($result->numberOfTestsRun(), 'Tests', $color, true);
    $this->printCountString($result->numberOfAssertions(), 'Assertions', $color, true);
    $this->printCountString($result->numberOfErrors(), 'Errors', $color);
    $this->printCountString($result->numberOfTestFailedEvents(), 'Failures', $color);
    $this->printCountString($result->numberOfWarnings(), 'Warnings', $color);
    $this->printCountString($result->numberOfPhpOrUserDeprecations(), 'Deprecations', $color);
    $this->printCountString($result->numberOfPhpunitDeprecations(), 'PHPUnit Deprecations', $color);
    $this->printCountString($result->numberOfNotices(), 'Notices', $color);
    $this->printCountString($result->numberOfTestSuiteSkippedEvents() + $result->numberOfTestSkippedEvents(), 'Skipped', $color);
    $this->printCountString($result->numberOfTestMarkedIncompleteEvents(), 'Incomplete', $color);
    $this->printCountString($result->numberOfTestsWithTestConsideredRiskyEvents(), 'Risky', $color);
    $this->printWithColor($color, '.');
    $this->printNumberOfIssuesIgnoredByBaseline($result);
}
RSS feed
Powered by Drupal