MediaWiki REL1_35
ComposerPhpunitXmlCoverageEdit.php
Go to the documentation of this file.
1<?php
2
30
31 public static function onEvent( $event ) {
32 $IP = dirname( dirname( __DIR__ ) );
33 // TODO: Support passing arbitrary directories for core (or extensions/skins).
34 $args = $event->getArguments();
35 if ( count( $args ) !== 1 ) {
36 throw new InvalidArgumentException( 'Pass extensions/$extensionName as an argument, ' .
37 'e.g. "composer phpunit:coverage-edit -- extensions/BoilerPlate"' );
38 }
39 $project = current( $args );
40 $phpunitXml = \PHPUnit\Util\Xml::loadFile( $IP . '/phpunit.xml.dist' );
41 $whitelist = iterator_to_array( $phpunitXml->getElementsByTagName( 'whitelist' ) );
43 foreach ( $whitelist as $childNode ) {
44 $childNode->parentNode->removeChild( $childNode );
45 }
46 $whitelistElement = $phpunitXml->createElement( 'whitelist' );
47 $whitelistElement->setAttribute( 'addUncoveredFilesFromWhitelist', 'false' );
48 // TODO: Use AutoloadClasses from extension.json to load the relevant directories
49 foreach ( [ 'includes', 'src', 'maintenance' ] as $dir ) {
50 $dirElement = $phpunitXml->createElement( 'directory', $project . '/' . $dir );
51 $dirElement->setAttribute( 'suffix', '.php' );
52 $whitelistElement->appendChild( $dirElement );
53
54 }
55 $phpunitXml->getElementsByTagName( 'filter' )->item( 0 )
56 ->appendChild( $whitelistElement );
57 $phpunitXml->formatOutput = true;
58 $phpunitXml->save( $IP . '/phpunit.xml' );
59 }
60}
$IP
Definition WebStart.php:49
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
if( $line===false) $args
Definition mcc.php:124