Manybubbles has uploaded a new change for review.

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


Change subject: Add a unit test to check if it broke any hooks
......................................................................

Add a unit test to check if it broke any hooks

This actually checks that all hooks are arrays.  They all should be and
we accidentally set one of them to a string a few commits ago.  It is easy
to miss the lack of a [] in the hooks definition.  This makes sure we
don't.

Change-Id: I62daf390064949b0c07b221581064120d1c9c72c
---
M CirrusSearch.php
M includes/CirrusSearchHooks.php
A tests/unit/HooksTest.php
3 files changed, 40 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/61/102461/1

diff --git a/CirrusSearch.php b/CirrusSearch.php
index 9d1e054..6b93c1e 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -229,6 +229,7 @@
 $wgHooks[ 'LinksUpdateComplete' ][] = 
'CirrusSearchHooks::linksUpdateCompletedHook';
 $wgHooks[ 'SoftwareInfo' ][] = 'CirrusSearchHooks::softwareInfoHook';
 $wgHooks[ 'SpecialSearchResultsPrepend' ][] = 
'CirrusSearchHooks::specialSearchResultsPrependHook';
+$wgHooks[ 'UnitTestsList' ][] = 'CirrusSearchHooks::unitTestsList';
 
 /**
  * i18n
diff --git a/includes/CirrusSearchHooks.php b/includes/CirrusSearchHooks.php
index 2dab5eb..c3b00fb 100644
--- a/includes/CirrusSearchHooks.php
+++ b/includes/CirrusSearchHooks.php
@@ -159,4 +159,14 @@
                JobQueueGroup::singleton()->push( $job );
                return true;
        }
+
+       /**
+        * Register Cirrus's unit tests.
+        * @param array $files containing tests
+        * @return bool
+        */
+       public static function getUnitTestsList( &$files ) {
+               $files = array_merge( $files, glob( __DIR__ . 
'/tests/unit/*Test.php' ) );
+               return true;
+       }
 }
diff --git a/tests/unit/HooksTest.php b/tests/unit/HooksTest.php
new file mode 100644
index 0000000..bdaafb1
--- /dev/null
+++ b/tests/unit/HooksTest.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Make sure cirrus doens't break any hooks.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+class HooksTest extends MediaWikiTestCase {
+       public function testHooksAreArrays() {
+               global $wgHooks;
+
+               foreach ( $wgHooks as $name => $array ) {
+                       $this->assertThat( $array, $this->isType( 'array' ),
+                               'All hooks should be arrays.' );
+               }
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62daf390064949b0c07b221581064120d1c9c72c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>

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

Reply via email to