MediaWiki master
PhpUnitTestListProcessor.php
Go to the documentation of this file.
1<?php
2
3declare( strict_types = 1 );
4
6
7use SimpleXMLElement;
8
13
14 private SimpleXMLElement $xml;
15
16 public function __construct( string $testListFile ) {
17 $this->xml = new SimpleXMLElement( file_get_contents( $testListFile ) );
18 }
19
25 public function getTestClasses(): array {
26 if ( !property_exists( $this->xml, "testCaseClass" ) ) {
27 return [];
28 }
29 return array_map(
30 fn ( $element ) => self::extractNamespace( (string)$element->attributes()["name"] ),
31 iterator_to_array( $this->xml->testCaseClass, false )
32 );
33 }
34
35 private static function extractNamespace( string $qualifiedClassName ): TestDescriptor {
36 $parts = explode( '\\', $qualifiedClassName );
37 $className = array_pop( $parts );
38 return new TestDescriptor( $className, $parts );
39 }
40}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81