Merge "Add Oracle version of update-keys.sql"
[lhc/web/wiklou.git] / tests / phpunit / suites / ExtensionsTestSuite.php
index eec773d..116065f 100644 (file)
@@ -1,18 +1,32 @@
 <?php
 /**
  * This test suite runs unit tests registered by extensions.
- * See http://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of how to register your tests.
+ * See https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of
+ * how to register your tests.
  */
 
 class ExtensionsTestSuite extends PHPUnit_Framework_TestSuite {
        public function __construct() {
                parent::__construct();
-               $files = array();
-               wfRunHooks( 'UnitTestsList', array( &$files ) );
-               foreach ( $files as $file ) {
-                       $this->addTestFile( $file );
+               $paths = array();
+               // Extensions can return a list of files or directories
+               wfRunHooks( 'UnitTestsList', array( &$paths ) );
+               foreach ( $paths as $path ) {
+                       if ( is_dir( $path ) ) {
+                               // If the path is a directory, search for test cases.
+                               // @since 1.24
+                               $suffixes = array(
+                                       'Test.php',
+                               );
+                               $fileIterator = new File_Iterator_Facade();
+                               $matchingFiles = $fileIterator->getFilesAsArray( $path, $suffixes );
+                               $this->addTestFiles( $matchingFiles );
+                       } else {
+                               // Add a single test case or suite class
+                               $this->addTestFile( $path );
+                       }
                }
-               if ( !count( $files ) ) {
+               if ( !count( $paths ) ) {
                        $this->addTest( new DummyExtensionsTest( 'testNothing' ) );
                }
        }