function simpletest_phpunit_xml_to_rows

Converts phpunit's junit xml output to an array.

The returned array of rows is in a format that can be inserted into the simpletest results table.

Parameters

$test_id: The current test ID.

$phpunit_xml_file: Path to the phpunit xml file.

2 calls to simpletest_phpunit_xml_to_rows()
PhpUnitErrorTest::testPhpUnitXmlParsing in drupal/core/modules/simpletest/tests/Drupal/simpletest/Tests/PhpUnitErrorTest.php
Test errors reported.
simpletest_run_phpunit_tests in drupal/core/modules/simpletest/simpletest.module
Executes phpunit tests and returns the results of the run.

File

drupal/core/modules/simpletest/simpletest.module, line 744
Provides testing functionality.

Code

function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
  $contents = @file_get_contents($phpunit_xml_file);
  if (!$contents) {
    return;
  }
  $xml = new SimpleXMLElement($contents);
  $records = array();
  foreach ($xml->testsuite as $testsuite) {
    foreach ($testsuite as $suite) {

      // The file element won't be on testcase objects created with
      // @dataProvider, so just use the one from the test suite at this level
      // because it should be the same.
      $file = (string) $suite
        ->attributes()->file;
      $testcases = simpletest_phpunit_find_testcases($suite);
      foreach ($testcases as $testcase) {
        $records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase, $file);
      }
    }
  }
  return $records;
}