public static function JUnitConverter::convertTestCaseToSimpletestRow in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Test/JUnitConverter.php \Drupal\Core\Test\JUnitConverter::convertTestCaseToSimpletestRow()
Converts a PHPUnit test case result to a {simpletest} result row.
@internal
Parameters
int $test_id: The current test ID.
\SimpleXMLElement $test_case: The PHPUnit test case represented as XML element.
Return value
array An array containing the {simpletest} result row.
2 calls to JUnitConverter::convertTestCaseToSimpletestRow()
- JUnitConverter::xmlElementToRows in core/
lib/ Drupal/ Core/ Test/ JUnitConverter.php - Parse test cases from XML to {simpletest} schema.
- JUnitConverterTest::testConvertTestCaseToSimpletestRow in core/
tests/ Drupal/ Tests/ Core/ Test/ JUnitConverterTest.php - @covers ::convertTestCaseToSimpletestRow
File
- core/
lib/ Drupal/ Core/ Test/ JUnitConverter.php, line 111
Class
- JUnitConverter
- Converts JUnit XML to Drupal's {simpletest} schema.
Namespace
Drupal\Core\TestCode
public static function convertTestCaseToSimpletestRow($test_id, \SimpleXMLElement $test_case) {
$message = '';
$pass = TRUE;
if ($test_case->failure) {
$lines = explode("\n", $test_case->failure);
$message = $lines[2];
$pass = FALSE;
}
if ($test_case->error) {
$message = $test_case->error;
$pass = FALSE;
}
$attributes = $test_case
->attributes();
$record = [
'test_id' => $test_id,
'test_class' => (string) $attributes->class,
'status' => $pass ? 'pass' : 'fail',
'message' => $message,
'message_group' => 'Other',
'function' => $attributes->class . '->' . $attributes->name . '()',
'line' => (int) $attributes->line ?: 0,
'file' => (string) $attributes->file,
];
return $record;
}