Merge "Add countUnreadNotifications to WatchedItemStore"
[lhc/web/wiklou.git] / tests / phpunit / suites / ExtensionsTestSuite.php
1 <?php
2 /**
3 * This test suite runs unit tests registered by extensions.
4 * See https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of
5 * how to register your tests.
6 */
7
8 class ExtensionsTestSuite extends PHPUnit_Framework_TestSuite {
9 public function __construct() {
10 parent::__construct();
11 $paths = [];
12 // Extensions can return a list of files or directories
13 Hooks::run( 'UnitTestsList', [ &$paths ] );
14 foreach ( $paths as $path ) {
15 if ( is_dir( $path ) ) {
16 // If the path is a directory, search for test cases.
17 // @since 1.24
18 $suffixes = [ 'Test.php' ];
19 $fileIterator = new File_Iterator_Facade();
20 $matchingFiles = $fileIterator->getFilesAsArray( $path, $suffixes );
21 $this->addTestFiles( $matchingFiles );
22 } else {
23 // Add a single test case or suite class
24 $this->addTestFile( $path );
25 }
26 }
27 if ( !$paths ) {
28 $this->addTest( new DummyExtensionsTest( 'testNothing' ) );
29 }
30 }
31
32 public static function suite() {
33 return new self;
34 }
35 }
36
37 /**
38 * Needed to avoid warnings like 'No tests found in class "ExtensionsTestSuite".'
39 * when no extensions with tests are used.
40 */
41 class DummyExtensionsTest extends MediaWikiTestCase {
42 public function testNothing() {
43 $this->assertTrue( true );
44 }
45 }