Hashar has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/333590 )
Change subject: TitleBlacklistTest singleton can now be destroyed
......................................................................
TitleBlacklistTest singleton can now be destroyed
The test suite set $wgTitleBlacklistSources with a fixture source of
directories. Unfortunately when running tests from MediaWiki core the
TitleBlacklist has already been set with empty value and thus setting
the global is a noop.
That later causes a test to fail because the blacklist is emtpy.
Add TitleBlacklistTest::destroySingleton() so a test can reset the
singleton when changing $wgTitleBlacklistSources.
Bug: T155980
Change-Id: I99c3185811ed7b2225953fa6960096985e97c4d2
---
M TitleBlacklist.list.php
M tests/phpunit/ApiQueryTitleBlacklistTest.php
2 files changed, 15 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TitleBlacklist
refs/changes/90/333590/1
diff --git a/TitleBlacklist.list.php b/TitleBlacklist.list.php
index efa41e3..254daef 100644
--- a/TitleBlacklist.list.php
+++ b/TitleBlacklist.list.php
@@ -17,6 +17,10 @@
*/
class TitleBlacklist {
private $mBlacklist = null, $mWhitelist = null;
+
+ /** @var TitleBlacklist */
+ protected static $instance = null;
+
const VERSION = 3; // Blacklist format
/**
@@ -25,12 +29,17 @@
* @return TitleBlacklist
*/
public static function singleton() {
- static $instance = null;
-
- if ( $instance === null ) {
- $instance = new self;
+ if ( self::$instance === null ) {
+ self::$instance = new self;
}
- return $instance;
+ return self::$instance;
+ }
+
+ /**
+ * Destroy/reset the current singleton instance.
+ */
+ public static function destroySingleton() {
+ self::$instance = null;
}
/**
diff --git a/tests/phpunit/ApiQueryTitleBlacklistTest.php
b/tests/phpunit/ApiQueryTitleBlacklistTest.php
index ab3a83a..e2164ba 100644
--- a/tests/phpunit/ApiQueryTitleBlacklistTest.php
+++ b/tests/phpunit/ApiQueryTitleBlacklistTest.php
@@ -22,6 +22,7 @@
parent::setUp();
$this->doLogin();
+ TitleBlacklist::destroySingleton();
$this->setMwGlobals( 'wgTitleBlacklistSources', array(
array(
'type' => 'file',
--
To view, visit https://gerrit.wikimedia.org/r/333590
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I99c3185811ed7b2225953fa6960096985e97c4d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TitleBlacklist
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits