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.
$test_id: The current test ID.
$phpunit_xml_file: Path to the phpunit xml file.
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;
}