You are here

public function PhpUnitTestRunner::summarizeResults in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::summarizeResults()
  2. 9 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::runTests().

Return value

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

File

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

Class

PhpUnitTestRunner
Run PHPUnit-based tests.

Namespace

Drupal\Core\Test

Code

public function summarizeResults(array $results) {
  $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;
}