You are here

function simpletest_run_phpunit_tests in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/simpletest.module \simpletest_run_phpunit_tests()

Executes PHPUnit tests and returns the results of the run.

Parameters

$test_id: The current test ID.

$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.

2 calls to simpletest_run_phpunit_tests()
SimpletestPhpunitRunCommandTest::testSimpletestPhpUnitRunCommand in core/modules/simpletest/tests/src/Unit/SimpletestPhpunitRunCommandTest.php
simpletest_run_tests in core/modules/simpletest/simpletest.module
Runs tests.

File

core/modules/simpletest/simpletest.module, line 181
Provides testing functionality.

Code

function simpletest_run_phpunit_tests($test_id, array $unescaped_test_classnames, &$status = NULL) {
  $phpunit_file = simpletest_phpunit_xml_filepath($test_id);
  simpletest_phpunit_run_command($unescaped_test_classnames, $phpunit_file, $status);

  // A $status of 0 = passed test, 1 = failed test, > 1 indicates segfault
  // timeout, or other type of failure.
  if ($status > 1) {

    // Something broke during the execution of phpunit.
    // Return an error record of all failed classes.
    $rows[] = [
      'test_id' => '1',
      'test_class' => implode(",", $unescaped_test_classnames),
      'status' => 'fail',
      'message' => 'PHPunit Test failed to complete',
      'message_group' => 'Other',
      'function' => implode(",", $unescaped_test_classnames),
      'line' => '0',
      'file' => $phpunit_file,
    ];
  }
  else {
    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file);
  }
  return $rows;
}