Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/69980


Change subject: Register unit tests automatically with MW
......................................................................

Register unit tests automatically with MW

Change-Id: I4931f66cee28d952540a11a3483e8ec419b17f95
---
M EducationProgram.hooks.php
1 file changed, 13 insertions(+), 27 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EducationProgram 
refs/changes/80/69980/1

diff --git a/EducationProgram.hooks.php b/EducationProgram.hooks.php
index 818f5ca..50065af 100644
--- a/EducationProgram.hooks.php
+++ b/EducationProgram.hooks.php
@@ -3,6 +3,9 @@
 namespace EducationProgram;
 
 use DatabaseUpdater;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+use SplFileInfo;
 use Title;
 use User;
 use SkinTemplate;
@@ -70,37 +73,20 @@
         * @return bool
         */
        public static function registerUnitTests( array &$files ) {
-               $testFiles = array(
-                       'Actions',
-                       'ArticleAdder',
-                       'ArticleStore',
-                       'CourseActivityView',
-                       'EPArticle',
-                       'Extension',
-                       'Menu',
-                       'Settings',
-                       'Specials',
-                       'Timeline',
-                       'UPCUserCourseFinder',
-                       'Utils',
+               // @codeCoverageIgnoreStart
+               $directoryIterator = new RecursiveDirectoryIterator( __DIR__ . 
'/tests/phpunit/' );
 
-                       'Events/EditEventCreator',
-                       'Events/EventGroup',
-                       'Events/EventQuery',
-                       'Events/EventStore',
-                       'Events/Event',
-                       'Events/RecentPageEventGrouper',
-
-                       'Store/CourseStore',
-
-                       'tables/Orgs',
-               );
-
-               foreach ( $testFiles as $file ) {
-                       $files[] = __DIR__ . '/tests/phpunit/' . $file . 
'Test.php';
+               /**
+                * @var SplFileInfo $fileInfo
+                */
+               foreach ( new RecursiveIteratorIterator( $directoryIterator ) 
as $fileInfo ) {
+                       if ( substr( $fileInfo->getFilename(), -8 ) === 
'Test.php' ) {
+                               $files[] = $fileInfo->getPathname();
+                       }
                }
 
                return true;
+               // @codeCoverageIgnoreEnd
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/69980
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4931f66cee28d952540a11a3483e8ec419b17f95
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to