From: Andrew Green Date: Mon, 22 Jun 2015 17:31:01 +0000 (-0400) Subject: resourceloader: Pass $context to getDependencies() in PHPUnit tests X-Git-Tag: 1.31.0-rc.0~10990^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=1dd6cfdf5061f93cabb8272b1029efbb128fd9b9;p=lhc%2Fweb%2Fwiklou.git resourceloader: Pass $context to getDependencies() in PHPUnit tests Send the ResourceLoaderContext param in calls to getDependencies() in PHPUnit tests for ResourceLoader. (This so an RL module in CentralNotice can emit a warning when that parameter is not provided, and still pass tests. Sending the parameter here will also be necessary when the parameter is made non-optional in the future.) Change-Id: I6033e03e2d8a46b4bd7f7a04ae13fd9f387ebd10 --- diff --git a/tests/phpunit/structure/ResourcesTest.php b/tests/phpunit/structure/ResourcesTest.php index 9178bdb719..2c92e305b6 100644 --- a/tests/phpunit/structure/ResourcesTest.php +++ b/tests/phpunit/structure/ResourcesTest.php @@ -47,6 +47,9 @@ class ResourcesTest extends MediaWikiTestCase { /** * Verify that nothing explicitly depends on the 'jquery' and 'mediawiki' modules. * They are always loaded, depending on them is unsupported and leads to unexpected behaviour. + * TODO Modules can dynamically choose dependencies based on context. This method does not + * test such dependencies. The same goes for testMissingDependencies() and + * testUnsatisfiableDependencies(). */ public function testIllegalDependencies() { $data = self::getAllModules(); @@ -57,7 +60,7 @@ class ResourcesTest extends MediaWikiTestCase { foreach ( $illegalDeps as $illegalDep ) { $this->assertNotContains( $illegalDep, - $module->getDependencies(), + $module->getDependencies( $data['context'] ), "Module '$moduleName' must not depend on '$illegalDep'" ); } @@ -73,7 +76,7 @@ class ResourcesTest extends MediaWikiTestCase { /** @var ResourceLoaderModule $module */ foreach ( $data['modules'] as $moduleName => $module ) { - foreach ( $module->getDependencies() as $dep ) { + foreach ( $module->getDependencies( $data['context'] ) as $dep ) { $this->assertContains( $dep, $validDeps, @@ -97,7 +100,7 @@ class ResourcesTest extends MediaWikiTestCase { /** @var ResourceLoaderModule $module */ foreach ( $data['modules'] as $moduleName => $module ) { $moduleTargets = $module->getTargets(); - foreach ( $module->getDependencies() as $dep ) { + foreach ( $module->getDependencies( $data['context'] ) as $dep ) { if ( !isset( $data['modules'][$dep] ) ) { // Missing dependencies reported by testMissingDependencies continue;