public static function provideMakeResourceLoaderLink() {
// @codingStandardsIgnoreStart Generic.Files.LineLength
return [
- // Load module script only
+ // Single only=scripts load
[
[ 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ],
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
. "});</script>"
],
- [
- // Don't condition wrap raw modules (like the startup module)
- [ 'test.raw', ResourceLoaderModule::TYPE_SCRIPTS ],
- '<script async src="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.raw&only=scripts&skin=fallback"></script>'
- ],
- // Load module styles only
- // This also tests the order the modules are put into the url
+ // Multiple only=styles load
[
[ [ 'test.baz', 'test.foo', 'test.bar' ], ResourceLoaderModule::TYPE_STYLES ],
- '<link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback">'
+ '<link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback"/>'
],
- // Load private module (only=scripts)
+ // Private embed (only=scripts)
[
[ 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ],
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
. "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});"
. "});</script>"
],
- // Load private module (combined)
- [
- [ 'test.quux', ResourceLoaderModule::TYPE_COMBINED ],
- "<script>(window.RLQ=window.RLQ||[]).push(function(){"
- . "mw.loader.implement(\"test.quux\",function($,jQuery){"
- . "mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
- . "\"]});});</script>"
- ],
- // Load no modules
- [
- [ [], ResourceLoaderModule::TYPE_COMBINED ],
- '',
- ],
- // noscript group
- [
- [ 'test.noscript', ResourceLoaderModule::TYPE_STYLES ],
- '<noscript><link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.noscript&only=styles&skin=fallback"></noscript>'
- ],
- // Load two modules in separate groups
- [
- [ [ 'test.group.foo', 'test.group.bar' ], ResourceLoaderModule::TYPE_COMBINED ],
- "<script>(window.RLQ=window.RLQ||[]).push(function(){"
- . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
- . "});</script>\n"
- . "<script>(window.RLQ=window.RLQ||[]).push(function(){"
- . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
- . "});</script>"
- ],
];
// @codingStandardsIgnoreEnd
}
/**
+ * See ResourceLoaderClientHtmlTest for full coverage.
+ *
* @dataProvider provideMakeResourceLoaderLink
* @covers OutputPage::makeResourceLoaderLink
- * @covers ResourceLoader::makeLoaderImplementScript
- * @covers ResourceLoader::makeModuleResponse
- * @covers ResourceLoader::makeInlineScript
- * @covers ResourceLoader::makeLoaderStateScript
- * @covers ResourceLoader::createLoaderURL
*/
public function testMakeResourceLoaderLink( $args, $expectedHtml ) {
$this->setMwGlobals( [
'wgResourceLoaderDebug' => false,
'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php',
- // Affects whether CDATA is inserted
- 'wgWellFormedXml' => false,
] );
$class = new ReflectionClass( 'OutputPage' );
$method = $class->getMethod( 'makeResourceLoaderLink' );
'styles' => '/* pref-animate=off */ .mw-icon { transition: none; }',
'group' => 'private',
] ),
- 'test.raw' => new ResourceLoaderTestModule( [
- 'script' => 'mw.test.baz( { token: 123 } );',
- 'isRaw' => true,
- ] ),
- 'test.noscript' => new ResourceLoaderTestModule( [
- 'styles' => '.mw-test-noscript { content: "style"; }',
- 'group' => 'noscript',
- ] ),
- 'test.group.bar' => new ResourceLoaderTestModule( [
- 'styles' => '.mw-group-bar { content: "style"; }',
- 'group' => 'bar',
- ] ),
- 'test.group.foo' => new ResourceLoaderTestModule( [
- 'styles' => '.mw-group-foo { content: "style"; }',
- 'group' => 'foo',
- ] ),
] );
$links = $method->invokeArgs( $out, $args );
- $actualHtml = implode( "\n", $links['html'] );
+ $actualHtml = strval( $links );
$this->assertEquals( $expectedHtml, $actualHtml );
}