| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\HookContainer\HookRunner; |
| 4 |
use MediaWiki\MediaWikiServices; |
| 5 |
use MediaWiki\Registration\ExtensionRegistry; |
| 6 |
use PHPUnit\Framework\TestSuite; |
| 7 |
use SebastianBergmann\FileIterator\Facade; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class ExtensionsTestSuite extends TestSuite { |
| 16 |
public function __construct() { |
| 17 |
parent::__construct(); |
| 18 |
|
| 19 |
if ( defined( 'MW_PHPUNIT_EXTENSIONS_TEST_PATHS' ) ) { |
| 20 |
$paths = MW_PHPUNIT_EXTENSIONS_TEST_PATHS; |
| 21 |
} else { |
| 22 |
$paths = []; |
| 23 |
|
| 24 |
$registry = ExtensionRegistry::getInstance(); |
| 25 |
foreach ( $registry->getAllThings() as $info ) { |
| 26 |
$paths[] = dirname( $info['path'] ) . '/tests/phpunit'; |
| 27 |
} |
| 28 |
|
| 29 |
( new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )->onUnitTestsList( $paths ); |
| 30 |
} |
| 31 |
|
| 32 |
foreach ( array_unique( $paths ) as $path ) { |
| 33 |
if ( is_dir( $path ) ) { |
| 34 |
|
| 35 |
|
| 36 |
$suffixes = [ 'Test.php' ]; |
| 37 |
$fileIterator = new Facade(); |
| 38 |
$matchingFiles = $fileIterator->getFilesAsArray( $path, $suffixes ); |
| 39 |
$this->addTestFiles( $matchingFiles ); |
| 40 |
} elseif ( is_file( $path ) ) { |
| 41 |
|
| 42 |
$this->addTestFile( $path ); |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public static function suite() { |
| 48 |
return new self; |
| 49 |
} |
| 50 |
} |