From b14ab776bdd506f6158daecaeda180c3099c1e4d Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 8 Mar 2019 20:58:16 +0000 Subject: [PATCH] resourceloader: Separate context from extraQuery in ClientHtmlTest The test was dual-purposing the same array both to create a ResourceLoaderContext object, and to pass further down as $extraQuery parameter. This meant that ResourceLoaderClientHtml::makeLoad, and indirectly ResourceLoader::makeLoaderQuery, did not have any control over the formatting of the query string, due to it forcing the key/value pairs regardless (in addition to being redundant). This is needed in order to omit debug=false by default, which is the next commit. Change-Id: I3c098a9a5055ec8f2b64319c6cadd13c030ba76a --- .../ResourceLoaderClientHtmlTest.php | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 3f9d52b450..d896e4ebbc 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -306,18 +306,21 @@ Deprecation message.' ] 'context' => [], 'modules' => [ 'test.unknown' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.styles.private' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.private' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '', ], [ @@ -325,30 +328,35 @@ Deprecation message.' ] // Eg. startup module 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '', ], [ - 'context' => [ 'sync' => '1' ], + 'context' => [], 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [ 'sync' => '1' ], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.scripts.user' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.user' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '', ], [ 'context' => [ 'debug' => 'true' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '' . "\n" . '', ], @@ -356,42 +364,49 @@ Deprecation message.' ] 'context' => [ 'debug' => 'false' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.styles.noscript' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.styles.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.scripts.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test', 'test.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.styles.pure', 'test.styles.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '' . "\n" . '' @@ -400,6 +415,7 @@ Deprecation message.' ] 'context' => [], 'modules' => [ 'test.ordering.a', 'test.ordering.e', 'test.ordering.b', 'test.ordering.d', 'test.ordering.c' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '' . "\n" . '' . "\n" @@ -421,8 +437,14 @@ Deprecation message.' ] * @covers ResourceLoader::makeLoaderQuery * @covers ResourceLoader::makeInlineScript */ - public function testMakeLoad( array $extraQuery, array $modules, $type, $expected ) { - $context = self::makeContext( $extraQuery ); + public function testMakeLoad( + array $contextQuery, + array $modules, + $type, + array $extraQuery, + $expected + ) { + $context = self::makeContext( $contextQuery ); $context->getResourceLoader()->register( self::makeSampleModules() ); $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery, false ); $expected = self::expandVariables( $expected ); -- 2.20.1