getName() === 'testcase' && (int) $parent->attributes()->tests > 0) { // Add the class attribute if the test case does not have one. This is the // case for tests using a data provider. The name of the parent testsuite // will be in the format class::method. if (!$element->attributes()->class) { $name = explode('::', $parent->attributes()->name, 2); $element->addAttribute('class', $name[0]); } return [$element]; } $test_cases = []; foreach ($element as $child) { $file = (string) $parent->attributes()->file; if ($file && !$child->attributes()->file) { $child->addAttribute('file', $file); } $test_cases = array_merge($test_cases, static::findTestCases($child, $element)); } return $test_cases; } /** * Converts a PHPUnit test case result to a {simpletest} result row. * * @param int $test_id * The current test ID. * @param \SimpleXMLElement $test_case * The PHPUnit test case represented as XML element. * * @return array * An array containing the {simpletest} result row. * * @internal */ 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; } }