3declare( strict_types = 1 );
17 private SimpleXMLElement $xml;
20 $this->xml =
new SimpleXMLElement( file_get_contents( $phpUnitXmlFile ) );
24 if ( !file_exists( $targetFile ) ) {
28 return $unitFile->containsSplitGroups();
32 if ( !property_exists( $this->xml,
"testsuites" ) ||
33 !property_exists( $this->xml->testsuites,
"testsuite" ) ) {
36 foreach ( $this->xml->testsuites->testsuite as $child ) {
37 if ( isset( $child->attributes()[
"name"] ) &&
38 strpos( (
string)$child->attributes()[
"name"],
"split_group_" ) === 0 ) {
46 $groups = count( $splitGroups );
47 for ( $i = 0; $i < $groups; $i++ ) {
48 $suite = $this->xml->testsuites->addChild(
"testsuite" );
49 $suite->addAttribute(
"name",
"split_group_" . $i );
50 $group = $splitGroups[$i];
51 if ( !empty( $group[
"list"] ) ) {
52 foreach ( $group[
"list"] as $file ) {
53 $suite->addChild(
"file", $file );
62 private function getSplitGroupSuite(
int $groupId ): SimpleXMLElement {
63 foreach ( $this->xml->testsuites->testsuite as $child ) {
64 if ( isset( $child->attributes()[
"name"] ) &&
65 (
string)$child->attributes()[
"name"] ===
"split_group_" . $groupId ) {
69 throw new SuiteGenerationException( $groupId );
81 $suite = $this->xml->testsuites->addChild(
"testsuite" );
82 $suite->addAttribute(
"name",
"split_group_" . ( $groupCount - 1 ) );
83 $suite->addChild(
"file",
"tests/phpunit/suites/ExtensionsParserTestSuite.php" );
85 $sandboxTest =
"extensions/Scribunto/tests/phpunit/Engines/LuaSandbox/SandboxTest.php";
86 if ( file_exists( $sandboxTest ) ) {
87 $suite = $this->getSplitGroupSuite( 0 );
88 $suite->addChild(
"file", $sandboxTest );
93 $dom =
new DOMDocument(
'1.0' );
94 $dom->preserveWhiteSpace =
false;
95 $dom->formatOutput =
true;
96 $dom->loadXML( $this->xml->asXML() );
97 file_put_contents( $targetXml, $dom->saveXML() );
if(!defined('MW_SETUP_CALLBACK'))