[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Move the hook onUnitTestsList on a separate file

2017-03-24 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344607 )

Change subject: Move the hook onUnitTestsList on a separate file
..


Move the hook onUnitTestsList on a separate file

It is not useful it stays in the main class, so separation
of concerns.

Change-Id: If08160ace6e4ed46a80203597b4b9d43efe9e60f
---
M extension.json
A src/Hooks.php
M src/MediaWikiFarm.php
M tests/phpunit/FunctionsTest.php
A tests/phpunit/HooksTest.php
5 files changed, 80 insertions(+), 44 deletions(-)

Approvals:
  Seb35: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 3304cf7..b8c184f 100644
--- a/extension.json
+++ b/extension.json
@@ -23,13 +23,14 @@
},
"Hooks": {
"UnitTestsList": [
-   "MediaWikiFarm::onUnitTestsList"
+   "MediaWikiFarmHooks::onUnitTestsList"
]
},
"AutoloadClasses": {
"MediaWikiFarm": "src/MediaWikiFarm.php",
"AbstractMediaWikiFarmScript": 
"src/AbstractMediaWikiFarmScript.php",
"MediaWikiFarmScript": "src/MediaWikiFarmScript.php",
+   "MediaWikiFarmHooks": "src/Hooks.php",
"MWFConfigurationException": "src/MediaWikiFarm.php"
},
"manifest_version": 1
diff --git a/src/Hooks.php b/src/Hooks.php
new file mode 100644
index 000..7c2fd12
--- /dev/null
+++ b/src/Hooks.php
@@ -0,0 +1,48 @@
+
+ * @license GPL-3.0+ GNU General Public License v3.0, or (at your option) any 
later version.
+ * @license AGPL-3.0+ GNU Affero General Public License v3.0, or (at your 
option) any later version.
+ */
+
+/**
+ * MediaWiki hooks.
+ *
+ * @package MediaWikiFarm
+ */
+class MediaWikiFarmHooks {
+
+   /**
+* Add files for unit testing.
+*
+* Only useful for MediaWiki 1.27- since MediaWiki 1.28+ autodiscovers 
these files.
+* Given this hook is never useful at runtime, it should be moved to a 
separate file
+* if MediaWiki runtime hooks are added in this file.
+*
+* @api
+*
+* @param string[] $files The test files.
+* @return true
+*/
+   public static function onUnitTestsList( array &$files ) {
+
+   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
+
+   $files[] = $dir . 'ConfigurationTest.php';
+   $files[] = $dir . 'ConstructionTest.php';
+   $files[] = $dir . 'FunctionsTest.php';
+   $files[] = $dir . 'HooksTest.php';
+   $files[] = $dir . 'InstallationIndependantTest.php';
+   $files[] = $dir . 'LoadingTest.php';
+   $files[] = $dir . 'LoggingTest.php';
+   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
+   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
+   $files[] = $dir . 'MonoversionInstallationTest.php';
+   $files[] = $dir . 'MultiversionInstallationTest.php';
+
+   return true;
+   }
+}
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5339e58..79dd68d 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -469,9 +469,10 @@
$GLOBALS['wgAutoloadClasses']['MediaWikiFarm'] = 
'src/MediaWikiFarm.php';

$GLOBALS['wgAutoloadClasses']['AbstractMediaWikiFarmScript'] = 
'src/AbstractMediaWikiFarmScript.php';
$GLOBALS['wgAutoloadClasses']['MediaWikiFarmScript'] = 
'src/MediaWikiFarmScript.php';
+   $GLOBALS['wgAutoloadClasses']['MediaWikiFarmHooks'] = 
'src/Hooks.php';

$GLOBALS['wgAutoloadClasses']['MWFConfigurationException'] = 
'src/MediaWikiFarm.php';
$GLOBALS['wgMessagesDirs']['MediaWikiFarm'] = array( 
'i18n' );
-   $GLOBALS['wgHooks']['UnitTestsList'][] = array( 
'MediaWikiFarm::onUnitTestsList' );
+   $GLOBALS['wgHooks']['UnitTestsList'][] = array( 
'MediaWikiFarmHooks::onUnitTestsList' );
}
}
 
@@ -1634,33 +1635,6 @@
}
 
throw new InvalidArgumentException( 'Argument of 
MediaWikiFarm->replaceVariables() must be a string or an array.' );
-   }
-
-   /**
-* Add files for unit testing.
-*
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param string[] $files The test files.
-* @return true
-*/
-   static function onUnitTestsList( array &$files ) {
-
-   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
-
-   $files[] = $dir . 'ConfigurationTest.php';
-   $files[] = $dir . 'ConstructionTest.php';
-   $files[] = $dir . 'FunctionsTest.php';
-   $files[] = $dir . 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Move the hook onUnitTestsList on a separate file

2017-03-24 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344607 )

Change subject: Move the hook onUnitTestsList on a separate file
..

Move the hook onUnitTestsList on a separate file

It is not useful it stays in the main class, so separation
of concerns.

Change-Id: If08160ace6e4ed46a80203597b4b9d43efe9e60f
---
A src/Hooks.php
M src/MediaWikiFarm.php
M tests/phpunit/FunctionsTest.php
A tests/phpunit/HooksTest.php
4 files changed, 76 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm 
refs/changes/07/344607/1

diff --git a/src/Hooks.php b/src/Hooks.php
new file mode 100644
index 000..7c2fd12
--- /dev/null
+++ b/src/Hooks.php
@@ -0,0 +1,48 @@
+
+ * @license GPL-3.0+ GNU General Public License v3.0, or (at your option) any 
later version.
+ * @license AGPL-3.0+ GNU Affero General Public License v3.0, or (at your 
option) any later version.
+ */
+
+/**
+ * MediaWiki hooks.
+ *
+ * @package MediaWikiFarm
+ */
+class MediaWikiFarmHooks {
+
+   /**
+* Add files for unit testing.
+*
+* Only useful for MediaWiki 1.27- since MediaWiki 1.28+ autodiscovers 
these files.
+* Given this hook is never useful at runtime, it should be moved to a 
separate file
+* if MediaWiki runtime hooks are added in this file.
+*
+* @api
+*
+* @param string[] $files The test files.
+* @return true
+*/
+   public static function onUnitTestsList( array &$files ) {
+
+   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
+
+   $files[] = $dir . 'ConfigurationTest.php';
+   $files[] = $dir . 'ConstructionTest.php';
+   $files[] = $dir . 'FunctionsTest.php';
+   $files[] = $dir . 'HooksTest.php';
+   $files[] = $dir . 'InstallationIndependantTest.php';
+   $files[] = $dir . 'LoadingTest.php';
+   $files[] = $dir . 'LoggingTest.php';
+   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
+   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
+   $files[] = $dir . 'MonoversionInstallationTest.php';
+   $files[] = $dir . 'MultiversionInstallationTest.php';
+
+   return true;
+   }
+}
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5339e58..b70ad71 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1636,33 +1636,6 @@
throw new InvalidArgumentException( 'Argument of 
MediaWikiFarm->replaceVariables() must be a string or an array.' );
}
 
-   /**
-* Add files for unit testing.
-*
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param string[] $files The test files.
-* @return true
-*/
-   static function onUnitTestsList( array &$files ) {
-
-   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
-
-   $files[] = $dir . 'ConfigurationTest.php';
-   $files[] = $dir . 'ConstructionTest.php';
-   $files[] = $dir . 'FunctionsTest.php';
-   $files[] = $dir . 'InstallationIndependantTest.php';
-   $files[] = $dir . 'LoadingTest.php';
-   $files[] = $dir . 'LoggingTest.php';
-   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
-   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
-   $files[] = $dir . 'MonoversionInstallationTest.php';
-   $files[] = $dir . 'MultiversionInstallationTest.php';
-
-   return true;
-   }
-
 
 
/*
diff --git a/tests/phpunit/FunctionsTest.php b/tests/phpunit/FunctionsTest.php
index ebf41b2..24d99de 100644
--- a/tests/phpunit/FunctionsTest.php
+++ b/tests/phpunit/FunctionsTest.php
@@ -85,21 +85,6 @@
}
 
/**
-* Test onUnitTestsList hook
-*
-* @covers MediaWikiFarm::onUnitTestsList
-*/
-   function testOnUnitTestsListHook() {
-
-   $testFiles = glob( dirname( __FILE__ ) . '/*Test.php' );
-
-   $array = array();
-   MediaWikiFarm::onUnitTestsList( $array );
-
-   $this->assertEquals( $testFiles, $array );
-   }
-
-   /**
 * Test arrayMerge
 *
 * @covers MediaWikiFarm::arrayMerge
diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php
new file mode 100644
index 000..a3be7d7
--- /dev/null
+++ b/tests/phpunit/HooksTest.php
@@ -0,0 +1,28 @@
+assertEquals( $testFiles, $array );
+   }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If08160ace6e4ed46a80203597b4b9d43efe9e60f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm