9 protected function setUp() {
14 SkinFactory::getDefaultInstance()->register(
24 'localBasePath' => realpath( __DIR__ ),
28 'noTemplateModule' => [],
30 'deprecatedModule' =>
$base + [
33 'deprecatedTomorrow' =>
$base + [
34 'deprecated' =>
'Will be removed tomorrow.'
37 'htmlTemplateModule' =>
$base + [
39 'templates/template.html',
40 'templates/template2.html',
44 'htmlTemplateUnknown' =>
$base + [
46 'templates/notfound.html',
50 'aliasedHtmlTemplateModule' =>
$base + [
52 'foo.html' =>
'templates/template.html',
53 'bar.html' =>
'templates/template2.html',
57 'templateModuleHandlebars' =>
$base + [
59 'templates/template_awesome.handlebars',
63 'aliasFooFromBar' =>
$base + [
65 'foo.foo' =>
'templates/template.bar',
86 $modules[
'templateModuleHandlebars'],
89 'mediawiki.template.handlebars',
96 'mediawiki.template.foo',
109 $rl->setName(
'testing' );
110 $this->assertEquals( $rl->getDependencies(), $expected );
117 'mw.log.warn("This page is using the deprecated ResourceLoader module \"deprecatedModule\".");',
120 'deprecatedTomorrow',
122 '"This page is using the deprecated ResourceLoader module \"deprecatedTomorrow\".\\n' .
123 "Will be removed tomorrow." .
136 $module->setName( $name );
138 $this->assertEquals( $module->getScript( $ctx ), $expected );
146 'localBasePath' => __DIR__ .
'/../../data/resourceloader',
147 'scripts' => [
'script-nosemi.js',
'script-comment.js' ],
149 $module->setName(
'testing' );
152 "/* eslint-disable */\nmw.foo()\n" .
154 "/* eslint-disable */\nmw.foo()\n// mw.bar();\n" .
156 $module->getScript( $ctx ),
157 'scripts are concatenated with a new-line'
174 'bar.css' => [
'media' =>
'print' ],
175 'screen.less' => [
'media' =>
'screen' ],
176 'screen-query.css' => [
'media' =>
'screen and (min-width: 400px)' ],
179 'default' =>
'quux-fallback.less',
192 $module->setName(
'testing' );
199 'quux-fallback.less',
204 array_map(
'basename', $module->getAllStyleFiles() )
214 return str_replace(
'/*@noflip*/ ',
'',
$css );
228 'styles' => [
'test.css' ],
230 $testModule->setName(
'testing' );
233 'styles' => [
'expected.css' ],
235 $expectedModule->setName(
'testing' );
249 $expectedModule->getStyles( $contextLtr ),
250 self::stripNoflip( $testModule->getStyles( $contextLtr ) ),
251 "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"
254 $expectedModule->getStyles( $contextLtr ),
255 self::stripNoflip( $testModule->getStyles( $contextRtl ) ),
256 "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"
269 $modules[
'templateModuleHandlebars'],
271 'templates/template_awesome.handlebars' =>
"wow\n",
277 'templates/template.html' =>
"<strong>hello</strong>\n",
278 'templates/template2.html' =>
"<div>goodbye</div>\n",
282 $modules[
'aliasedHtmlTemplateModule'],
284 'foo.html' =>
"<strong>hello</strong>\n",
285 'bar.html' =>
"<div>goodbye</div>\n",
301 $rl->setName(
'testing' );
303 if ( $expected ===
false ) {
304 $this->setExpectedException( MWException::class );
307 $this->assertEquals( $rl->getTemplates(), $expected );
318 'styles' => [
'bom.css' ],
320 $testModule->setName(
'testing' );
322 substr( file_get_contents(
"$basePath/bom.css" ), 0, 10 ),
323 "\xef\xbb\xbf.efbbbf",
324 'File has leading BOM'
330 [
'all' =>
".efbbbf_bom_char_at_start_of_file {}\n" ],
331 'Leading BOM removed when concatenating files'
343 $version = $module->getVersionHash(
$context );
345 'lessVars' => [
'key' =>
'value' ],
347 $this->assertNotEquals(
349 $module->getVersionHash(
$context ),
350 'Using less variables is significant'
testBomConcatenation()
ResourceLoaderFileModule::stripBom.
static providerTemplateDependencies()
testDeprecatedModules( $name, $expected)
providerDeprecatedModules ResourceLoaderFileModule::getScript
testGetVersionHash()
ResourceLoaderFileModule::getDefinitionSummary.
testGetAllSkinStyleFiles()
ResourceLoaderFileModule::getAllStyleFiles ResourceLoaderFileModule::getAllSkinStyleFiles ResourceLoa...
testMixedCssAnnotations()
What happens when you mix @embed and @noflip? This really is an integration test, but oh well.
static stripNoflip( $css)
Strip @noflip annotations from CSS code.
static providerDeprecatedModules()
testGetScript()
ResourceLoaderFileModule::getScript.
testTemplateDependencies( $module, $expected)
providerTemplateDependencies ResourceLoaderFileModule::__construct ResourceLoaderFileModule::getDepen...
static providerGetTemplates()
testGetTemplates( $module, $expected)
providerGetTemplates ResourceLoaderFileModule::getTemplates
ResourceLoader module based on local JavaScript/CSS files.
getResourceLoaderContext( $options=[], ResourceLoader $rl=null)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context