function PhpUnitTestRunner::execute

Same name and namespace in other branches
  1. 11.x 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[] $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 179

Class

PhpUnitTestRunner
Run PHPUnit-based tests.

Namespace

Drupal\Core\Test

Code

public function execute(TestRun $test_run, array $unescaped_test_classnames, ?int &$status = NULL) : array {
    $phpunit_file = $this->xmlLogFilePath($test_run->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_run->id(), $phpunit_file);
    }
    return [
        [
            'test_id' => $test_run->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.