resourceloader: Pass $context to getDependencies() in PHPUnit tests
authorAndrew Green <andrew.green.df@gmail.com>
Mon, 22 Jun 2015 17:31:01 +0000 (13:31 -0400)
committerKrinkle <krinklemail@gmail.com>
Wed, 24 Jun 2015 20:28:07 +0000 (20:28 +0000)
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

index 9178bdb..2c92e30 100644 (file)
@@ -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;