From 330444a4f91d7b5dc1416eddb4035e95ac711fdf Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 27 Mar 2014 17:58:03 -0700 Subject: [PATCH] resourceloader: Add unit test to ensure absence of illegal dependencies Loading these can cause side-effects and is just redundant in general. Change-Id: Ic8b4ed45d4d42172a456cc5eaf314c41e4e6fd18 --- resources/Resources.php | 2 -- tests/phpunit/structure/ResourcesTest.php | 15 +++++++++++++++ tests/qunit/QUnitTestResources.php | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/resources/Resources.php b/resources/Resources.php index 00251efaa4..642897c577 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -373,7 +373,6 @@ return array( 'resources/src/jquery.ui-themes/vector/jquery.ui.theme.css', ), ), - 'dependencies' => 'jquery', 'group' => 'jquery.ui', ), 'jquery.ui.widget' => array( @@ -572,7 +571,6 @@ return array( // Effects 'jquery.effects.core' => array( 'scripts' => 'resources/lib/jquery.effects/jquery.effects.core.js', - 'dependencies' => 'jquery', 'group' => 'jquery.ui', ), 'jquery.effects.blind' => array( diff --git a/tests/phpunit/structure/ResourcesTest.php b/tests/phpunit/structure/ResourcesTest.php index cce1b7ecfb..cfcc771486 100644 --- a/tests/phpunit/structure/ResourcesTest.php +++ b/tests/phpunit/structure/ResourcesTest.php @@ -34,6 +34,21 @@ class ResourcesTest extends MediaWikiTestCase { $this->assertTrue( strpos( $cssText, '@media' ) === false, 'Stylesheets should not both specify "media" and contain @media' ); } + public function testDependencies() { + $data = self::getAllModules(); + $illegalDeps = array( 'jquery', 'mediawiki' ); + + foreach ( $data['modules'] as $moduleName => $module ) { + foreach ( $illegalDeps as $illegalDep ) { + $this->assertNotContains( + $illegalDep, + $module->getDependencies(), + "Module '$moduleName' must not depend on '$illegalDep'" + ); + } + } + } + /** * Get all registered modules from ResouceLoader. */ diff --git a/tests/qunit/QUnitTestResources.php b/tests/qunit/QUnitTestResources.php index 607c4352b0..74ea58ee18 100644 --- a/tests/qunit/QUnitTestResources.php +++ b/tests/qunit/QUnitTestResources.php @@ -94,7 +94,6 @@ return array( 'jquery.tabIndex', 'jquery.tablesorter', 'jquery.textSelection', - 'mediawiki', 'mediawiki.api', 'mediawiki.api.parse', 'mediawiki.api.watch', -- 2.20.1