function PhpUnitTestRunner::execute

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Test/PhpUnitTestRunner.php \Drupal\Core\Test\PhpUnitTestRunner::execute()

Executes PHPUnit tests and returns the results of the run.

@internal

Parameters

\Drupal\Core\Test\TestRun $test_run: The test run object.

string $test_class_name: A fully qualified test class name.

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 172

Class

PhpUnitTestRunner
Run PHPUnit-based tests.

Namespace

Drupal\Core\Test

Code

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

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