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