Jeroen De Dauw has submitted this change and it was merged.

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(-)

Approvals:
  Jeroen De Dauw: Verified; Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: I4931f66cee28d952540a11a3483e8ec419b17f95
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to