/** * @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(array('wgResourceLoaderDebug' => false, 'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php', 'wgWellFormedXml' => false)); $class = new ReflectionClass('OutputPage'); $method = $class->getMethod('makeResourceLoaderLink'); $method->setAccessible(true); $ctx = new RequestContext(); $ctx->setSkin(SkinFactory::getDefaultInstance()->makeSkin('fallback')); $ctx->setLanguage('en'); $out = new OutputPage($ctx); $rl = $out->getResourceLoader(); $rl->setMessageBlobStore(new NullMessageBlobStore()); $rl->register(array('test.foo' => new ResourceLoaderTestModule(array('script' => 'mw.test.foo( { a: true } );', 'styles' => '.mw-test-foo { content: "style"; }')), 'test.bar' => new ResourceLoaderTestModule(array('script' => 'mw.test.bar( { a: true } );', 'styles' => '.mw-test-bar { content: "style"; }')), 'test.baz' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { a: true } );', 'styles' => '.mw-test-baz { content: "style"; }')), 'test.quux' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { token: 123 } );', 'styles' => '/* pref-animate=off */ .mw-icon { transition: none; }', 'group' => 'private')), 'test.raw' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { token: 123 } );', 'isRaw' => true)), 'test.noscript' => new ResourceLoaderTestModule(array('styles' => '.mw-test-noscript { content: "style"; }', 'group' => 'noscript')), 'test.group.bar' => new ResourceLoaderTestModule(array('styles' => '.mw-group-bar { content: "style"; }', 'group' => 'bar')), 'test.group.foo' => new ResourceLoaderTestModule(array('styles' => '.mw-group-foo { content: "style"; }', 'group' => 'foo')))); $links = $method->invokeArgs($out, $args); $actualHtml = implode("\n", $links['html']); $this->assertEquals($expectedHtml, $actualHtml); }