function simpletest_phpunit_find_testcases in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/simpletest/simpletest.module \simpletest_phpunit_find_testcases()
Finds all test cases recursively from a test suite list.
Parameters
\SimpleXMLElement $element: The PHPUnit xml to search for test cases.
\SimpleXMLElement $suite: (Optional) The parent of the current element. Defaults to NULL.
Return value
array A list of all test cases.
1 call to simpletest_phpunit_find_testcases()
- simpletest_phpunit_xml_to_rows in core/
modules/ simpletest/ simpletest.module - Converts PHPUnit's JUnit XML output to an array.
File
- core/
modules/ simpletest/ simpletest.module, line 719 - Provides testing functionality.
Code
function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXMLElement $parent = NULL) {
$testcases = array();
if (!isset($parent)) {
$parent = $element;
}
if ($element
->getName() === 'testcase' && (int) $parent
->attributes()->tests > 0) {
// Add the class attribute if the testcase 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]);
}
$testcases[] = $element;
}
else {
foreach ($element as $child) {
$file = (string) $parent
->attributes()->file;
if ($file && !$child
->attributes()->file) {
$child
->addAttribute('file', $file);
}
$testcases = array_merge($testcases, simpletest_phpunit_find_testcases($child, $element));
}
}
return $testcases;
}