Umherirrender has uploaded a new change for review.
https://gerrit.wikimedia.org/r/166752
Change subject: Refactor hook handling in ResourceLoaderTest
......................................................................
Refactor hook handling in ResourceLoaderTest
No need to set a global $wgHooks, just set it for the current test.
Change-Id: Ic3e82608efa617a5a7f7c31365d748222bc6d6da
---
M tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
1 file changed, 11 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/52/166752/1
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
index 7664d5b..78bfdf3 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
@@ -2,8 +2,6 @@
class ResourceLoaderTest extends ResourceLoaderTestCase {
- protected static $resourceLoaderRegisterModulesHook;
-
protected function setUp() {
parent::setUp();
@@ -30,17 +28,6 @@
) );
}
- /* Hook Methods */
-
- /**
- * ResourceLoaderRegisterModules hook
- */
- public static function resourceLoaderRegisterModules( &$resourceLoader
) {
- self::$resourceLoaderRegisterModulesHook = true;
-
- return true;
- }
-
/* Provider Methods */
public static function provideValidModules() {
return array(
@@ -56,9 +43,18 @@
* @covers ResourceLoader::__construct
*/
public function testCreatingNewResourceLoaderCallsRegistrationHook() {
- self::$resourceLoaderRegisterModulesHook = false;
+ $resourceLoaderRegisterModulesHook = false;
+
+ $this->setMwGlobals( 'wgHooks', array(
+ 'ResourceLoaderRegisterModules' => array(
+ function ( &$resourceLoader ) use (
&$resourceLoaderRegisterModulesHook ) {
+ $resourceLoaderRegisterModulesHook =
true;
+ }
+ )
+ ) );
+
$resourceLoader = new ResourceLoader();
- $this->assertTrue( self::$resourceLoaderRegisterModulesHook );
+ $this->assertTrue( $resourceLoaderRegisterModulesHook, 'Hook
ResourceLoaderRegisterModules called' );
return $resourceLoader;
}
@@ -242,7 +238,3 @@
}
}
}
-
-/* Hooks */
-global $wgHooks;
-$wgHooks['ResourceLoaderRegisterModules'][] =
'ResourceLoaderTest::resourceLoaderRegisterModules';
--
To view, visit https://gerrit.wikimedia.org/r/166752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3e82608efa617a5a7f7c31365d748222bc6d6da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits