Go to the documentation of this file.
9 protected function setUp() {
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 );
148 'localBasePath' => __DIR__ .
'/../../data/resourceloader',
149 'scripts' => [
'script-nosemi.js',
'script-comment.js' ],
151 $module->setName(
'testing' );
154 "/* eslint-disable */\nmw.foo()\n" .
156 "/* eslint-disable */\nmw.foo()\n// mw.bar();\n" .
158 $module->getScript( $ctx ),
159 'scripts are concatenated with a new-line'
176 'bar.css' => [
'media' =>
'print' ],
177 'screen.less' => [
'media' =>
'screen' ],
178 'screen-query.css' => [
'media' =>
'screen and (min-width: 400px)' ],
181 'default' =>
'quux-fallback.less',
194 $module->setName(
'testing' );
201 'quux-fallback.less',
206 array_map(
'basename', $module->getAllStyleFiles() )
216 return str_replace(
'/*@noflip*/ ',
'',
$css );
232 'styles' => [
'test.css' ],
234 $testModule->setName(
'testing' );
237 'styles' => [
'expected.css' ],
239 $expectedModule->setName(
'testing' );
253 $expectedModule->getStyles( $contextLtr ),
255 "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"
258 $expectedModule->getStyles( $contextLtr ),
260 "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"
273 $modules[
'templateModuleHandlebars'],
275 'templates/template_awesome.handlebars' =>
"wow\n",
281 'templates/template.html' =>
"<strong>hello</strong>\n",
282 'templates/template2.html' =>
"<div>goodbye</div>\n",
286 $modules[
'aliasedHtmlTemplateModule'],
288 'foo.html' =>
"<strong>hello</strong>\n",
289 'bar.html' =>
"<div>goodbye</div>\n",
305 $rl->setName(
'testing' );
307 if ( $expected ===
false ) {
311 $this->assertEquals( $rl->getTemplates(), $expected );
322 'styles' => [
'bom.css' ],
324 $testModule->setName(
'testing' );
326 substr( file_get_contents(
"$basePath/bom.css" ), 0, 10 ),
327 "\xef\xbb\xbf.efbbbf",
328 'File has leading BOM'
334 [
'all' =>
".efbbbf_bom_char_at_start_of_file {}\n" ],
335 'Leading BOM removed when concatenating files'
344 $basePath = __DIR__ .
'/../../data/less/module';
347 'styles' => [
'styles.less' ],
349 'lessVars' => [
'foo' =>
'2px',
'Foo' =>
'#eeeeee' ]
351 $module->setName(
'test.less' );
352 $styles = $module->getStyles(
$context );
353 $this->assertStringEqualsFile(
$basePath .
'/styles.css', $styles[
'all'] );
365 $version = $module->getVersionHash(
$context );
367 'lessVars' => [
'key' =>
'value' ],
369 $this->assertNotEquals(
371 $module->getVersionHash(
$context ),
372 'Using less variables is significant'
static providerDeprecatedModules()
testLessFileCompilation()
ResourceLoaderFileModule::compileLessFile.
testTemplateDependencies( $module, $expected)
providerTemplateDependencies ResourceLoaderFileModule::__construct ResourceLoaderFileModule::getDepen...
testGetAllSkinStyleFiles()
ResourceLoaderFileModule::getAllStyleFiles ResourceLoaderFileModule::getAllSkinStyleFiles ResourceLoa...
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
ResourceLoader module based on local JavaScript/CSS files.
static providerGetTemplates()
Allows to change the fields on the form that will be generated $name
testGetVersionHash()
ResourceLoaderFileModule::getDefinitionSummary ResourceLoaderFileModule::getFileHashes.
testGetScript()
ResourceLoaderFileModule::getScript ResourceLoaderFileModule::getScriptFiles ResourceLoaderFileModule...
static stripNoflip( $css)
Strip @noflip annotations from CSS code.
testMixedCssAnnotations()
What happens when you mix @embed and @noflip? This really is an integration test, but oh well.
testDeprecatedModules( $name, $expected)
providerDeprecatedModules ResourceLoaderFileModule::getScript
getResourceLoaderContext( $options=[], ResourceLoader $rl=null)
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
testGetTemplates( $module, $expected)
providerGetTemplates ResourceLoaderFileModule::getTemplates
static providerTemplateDependencies()
testBomConcatenation()
ResourceLoaderFileModule::stripBom.
static getDefaultInstance()