function PhpUnitTestRunner::runTests

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::runTests()

Executes PHPUnit tests and returns the results of the run.

@internal

Parameters

int $test_id: The current test ID.

string[] $unescaped_test_classnames: An array of test class names, including full namespaces, to be passed as a regular expression to PHPUnit's --filter option.

int $status: (optional) The exit status code of the PHPUnit process will be assigned to this variable.

Return value

array The parsed results of PHPUnit's JUnit XML output, in the format of {simpletest}'s schema.

File

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

Class

PhpUnitTestRunner
Run PHPUnit-based tests.

Namespace

Drupal\Core\Test

Code

public function runTests($test_id, array $unescaped_test_classnames, &$status = NULL) {
    $phpunit_file = $this->xmlLogFilePath($test_id);
    // Store output from our test run.
    $output = [];
    $this->runCommand($unescaped_test_classnames, $phpunit_file, $status, $output);
    if ($status == TestStatus::PASS) {
        return JUnitConverter::xmlToRows($test_id, $phpunit_file);
    }
    return [
        [
            'test_id' => $test_id,
            'test_class' => implode(",", $unescaped_test_classnames),
            'status' => TestStatus::label($status),
            'message' => 'PHPUnit Test failed to complete; Error: ' . implode("\n", $output),
            'message_group' => 'Other',
            'function' => implode(",", $unescaped_test_classnames),
            'line' => '0',
            'file' => $phpunit_file,
        ],
    ];
}

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