Skip to content

Instantly share code, notes, and snippets.

@Tjitse-E
Created January 3, 2023 13:46
Show Gist options
  • Save Tjitse-E/a7a7400d77a17075c5778355a1943101 to your computer and use it in GitHub Desktop.
Save Tjitse-E/a7a7400d77a17075c5778355a1943101 to your computer and use it in GitHub Desktop.
Update PHPUnit config from 6.2 to 9.5
<?php
$doc1 = new DOMDocument();
$doc1->load('dev/tests/integration/phpunit.xml');
$xmlToAdd = new DOMDocument();
$xmlToAdd->loadXML('<coverage>
<exclude>
<directory suffix=".php">../../../app/code/Magento</directory>
<directory>../../../app/code/*/*/Test</directory>
<directory>../../../app/code/*/*/Setup</directory>
<directory suffix="registration.php">../../../app/code</directory>
</exclude>
<include>
<directory>../../../app/code</directory>
</include>
</coverage>');
/** @var DOMElement $phpunit */
$phpunit = $doc1->getElementsByTagName('phpunit')->item(0);
// Add code coverage section
$coverage = $xmlToAdd->getElementsByTagName('coverage')->item(0);
$copiedItem = $doc1->importNode($coverage, true);
$phpunit->appendChild($copiedItem);
// Remove filter section
$filterSection = $doc1->getElementsByTagName('filter')->item(0);
$phpunit->removeChild($filterSection);
// Attribute
$phpunit->removeAttribute('xsi:noNamespaceSchemaLocation');
$phpunit->setAttribute('xsi:noNamespaceSchemaLocation', 'http://schema.phpunit.de/9.5/phpunit.xsd');
$doc1->save('output.xml');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment