function PhpUnitTestRunner::summarizeResults

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::summarizeResults()
  2. 8.9.x core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::summarizeResults()
  3. 10 core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::summarizeResults()

Tallies test results per test class.

@internal

Parameters

string[][] $results: Array of results in the {simpletest} schema. Can be the return value of PhpUnitTestRunner::execute().

Return value

int[][] Array of status tallies, keyed by test class name and status type.

File

core/lib/Drupal/Core/Test/PhpUnitTestRunner.php, line 223

Class

PhpUnitTestRunner
Run PHPUnit-based tests.

Namespace

Drupal\Core\Test

Code

public function summarizeResults(array $results) : array {
    $summaries = [];
    foreach ($results as $result) {
        if (!isset($summaries[$result['test_class']])) {
            $summaries[$result['test_class']] = [
                '#pass' => 0,
                '#fail' => 0,
                '#exception' => 0,
                '#debug' => 0,
            ];
        }
        switch ($result['status']) {
            case 'pass':
                $summaries[$result['test_class']]['#pass']++;
                break;
            case 'fail':
                $summaries[$result['test_class']]['#fail']++;
                break;
            case 'exception':
                $summaries[$result['test_class']]['#exception']++;
                break;
            case 'debug':
                $summaries[$result['test_class']]['#debug']++;
                break;
        }
    }
    return $summaries;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.