9 protected function setUp() {
24 'localBasePath' => realpath( __DIR__ ),
28 'noTemplateModule' => [],
30 'deprecatedModule' =>
$base + [
33 'deprecatedTomorrow' =>
$base + [
35 'message' =>
'Will be removed tomorrow.'
39 'htmlTemplateModule' =>
$base + [
41 'templates/template.html',
42 'templates/template2.html',
46 'aliasedHtmlTemplateModule' =>
$base + [
48 'foo.html' =>
'templates/template.html',
49 'bar.html' =>
'templates/template2.html',
53 'templateModuleHandlebars' =>
$base + [
55 'templates/template_awesome.handlebars',
59 'aliasFooFromBar' =>
$base + [
61 'foo.foo' =>
'templates/template.bar',
82 $modules[
'templateModuleHandlebars'],
85 'mediawiki.template.handlebars',
89 $modules[
'aliasFooFromBar'],
92 'mediawiki.template.foo',
105 $rl->setName(
'testing' );
106 $this->assertEquals( $rl->getDependencies(), $expected );
113 'mw.log.warn("This page is using the deprecated ResourceLoader module \"deprecatedModule\".");',
116 'deprecatedTomorrow',
118 '"This page is using the deprecated ResourceLoader module \"deprecatedTomorrow\".\\n' .
119 "Will be removed tomorrow." .
132 $rl->setName( $name );
134 $this->assertEquals( $rl->getScript( $ctx ), $expected );
150 'bar.css' => [
'media' =>
'print' ],
151 'screen.less' => [
'media' =>
'screen' ],
152 'screen-query.css' => [
'media' =>
'screen and (min-width: 400px)' ],
155 'default' =>
'quux-fallback.less',
168 $module->setName(
'testing' );
175 'quux-fallback.less',
180 array_map(
'basename', $module->getAllStyleFiles() )
190 return str_replace(
'/*@noflip*/ ',
'',
$css );
204 'styles' => [
'test.css' ],
206 $testModule->setName(
'testing' );
209 'styles' => [
'expected.css' ],
211 $expectedModule->setName(
'testing' );
219 $expectedModule->getStyles( $contextLtr ),
220 self::stripNoflip( $testModule->getStyles( $contextLtr ) ),
221 "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"
224 $expectedModule->getStyles( $contextLtr ),
225 self::stripNoflip( $testModule->getStyles( $contextRtl ) ),
226 "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"
239 $modules[
'templateModuleHandlebars'],
241 'templates/template_awesome.handlebars' =>
"wow\n",
245 $modules[
'htmlTemplateModule'],
247 'templates/template.html' =>
"<strong>hello</strong>\n",
248 'templates/template2.html' =>
"<div>goodbye</div>\n",
252 $modules[
'aliasedHtmlTemplateModule'],
254 'foo.html' =>
"<strong>hello</strong>\n",
255 'bar.html' =>
"<div>goodbye</div>\n",
267 $rl->setName(
'testing' );
269 $this->assertEquals( $rl->getTemplates(), $expected );
276 'styles' => [
'bom.css' ],
278 $testModule->setName(
'testing' );
280 substr( file_get_contents(
"$basePath/bom.css" ), 0, 10 ),
281 "\xef\xbb\xbf.efbbbf",
282 'File has leading BOM'
287 $testModule->getStyles( $contextLtr ),
288 [
'all' =>
".efbbbf_bom_char_at_start_of_file {}\n" ],
289 'Leading BOM removed when concatenating files'
testTemplateDependencies($module, $expected)
providerTemplateDependencies ResourceLoaderFileModule::__construct ResourceLoaderFileModule::getDepen...
testMixedCssAnnotations()
What happens when you mix and ? This really is an integration test, but oh well. ...
static stripNoflip($css)
Strip annotations from CSS code.
testDeprecatedModules($name, $expected)
providerDeprecatedModules ResourceLoaderFileModule::getScript
getResourceLoaderContext($lang= 'en', $dir= 'ltr')
static providerDeprecatedModules()
ResourceLoader module based on local JavaScript/CSS files.
testGetTemplates($module, $expected)
providerGetTemplates ResourceLoaderFileModule::getTemplates
static providerTemplateDependencies()
testGetAllSkinStyleFiles()
ResourceLoaderFileModule::getAllStyleFiles ResourceLoaderFileModule::getAllSkinStyleFiles ResourceLoa...
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
static getDefaultInstance()
static providerGetTemplates()
Allows to change the fields on the form that will be generated $name