diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2019-03-08 20:58:16 +0000 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2019-03-08 21:29:09 +0000 |
commit | b14ab776bdd506f6158daecaeda180c3099c1e4d (patch) | |
tree | 4a5eaa80357fd32fdfc56307dc80603d4a6f79ae /tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php | |
parent | 9a4a754231482f3faf0061be1a177860654bcae7 (diff) | |
download | mediawikicore-b14ab776bdd506f6158daecaeda180c3099c1e4d.tar.gz mediawikicore-b14ab776bdd506f6158daecaeda180c3099c1e4d.zip |
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
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 3f9d52b45076..d896e4ebbcd8 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' => '<style>.private{}</style>', ], [ 'context' => [], 'modules' => [ 'test.private' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.private@{blankVer}",null,{"css":[]});});</script>', ], [ @@ -325,30 +328,35 @@ Deprecation message.' ] // Eg. startup module 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '<script async="" src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback"></script>', ], [ - 'context' => [ 'sync' => '1' ], + 'context' => [], 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [ 'sync' => '1' ], 'output' => '<script src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback&sync=1"></script>', ], [ 'context' => [], 'modules' => [ 'test.scripts.user' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts.user\u0026only=scripts\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>', ], [ 'context' => [], 'modules' => [ 'test.user' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.user\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>', ], [ 'context' => [ 'debug' => 'true' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.mixed&only=styles&skin=fallback"/>' . "\n" . '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>', ], @@ -356,42 +364,49 @@ Deprecation message.' ] 'context' => [ 'debug' => 'false' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.mixed%2Cpure&only=styles&skin=fallback"/>', ], [ 'context' => [], 'modules' => [ 'test.styles.noscript' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '<noscript><link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.noscript&only=styles&skin=fallback"/></noscript>', ], [ 'context' => [], 'modules' => [ 'test.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.shouldembed@09p30q0",null,{"css":[]});});</script>', ], [ 'context' => [], 'modules' => [ 'test.styles.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '<style>.shouldembed{}</style>', ], [ 'context' => [], 'modules' => [ 'test.scripts.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.state({"test.scripts.shouldembed":"ready"});});</script>', ], [ 'context' => [], 'modules' => [ 'test', 'test.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, + 'extra' => [], 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test\u0026skin=fallback");mw.loader.implement("test.shouldembed@09p30q0",null,{"css":[]});});</script>', ], [ 'context' => [], 'modules' => [ 'test.styles.pure', 'test.styles.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, + 'extra' => [], 'output' => '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' . "\n" . '<style>.shouldembed{}</style>' @@ -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' => '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.ordering.a%2Cb&only=styles&skin=fallback"/>' . "\n" . '<style>.orderingC{}.orderingD{}</style>' . "\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 ); |