From 1dd6cfdf5061f93cabb8272b1029efbb128fd9b9 Mon Sep 17 00:00:00 2001 From: Andrew Green Date: Mon, 22 Jun 2015 13:31:01 -0400 Subject: [PATCH] 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 --- tests/phpunit/structure/ResourcesTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; -- 2.20.1