11 $this->assertInstanceOf(
'ResourceLoaderWikiModule', $module );
20 [ [
'foo' =>
'baz' ] ],
22 [ [
'scripts' => [
'MediaWiki:Common.js' ] ] ],
32 $module->setConfig( $config );
35 $getPages =
new ReflectionMethod( $module,
'getPages' );
36 $getPages->setAccessible(
true );
38 $this->assertEquals( $expected,
$out );
42 $settings = self::getSettings() + [
48 'styles' => [
'MediaWiki:Common.css' ],
49 'scripts' => [
'MediaWiki:Common.js' ],
55 'MediaWiki:Common.js' => [
'type' =>
'script' ],
56 'MediaWiki:Common.css' => [
'type' =>
'style' ]
59 'MediaWiki:Common.js' => [
'type' =>
'script' ],
62 'MediaWiki:Common.css' => [
'type' =>
'style' ],
66 [
'UseSiteJs' =>
false,
'UseSiteCss' =>
false ]
79 $this->assertEquals( $expected, $module->getGroup() );
87 [ [
'group' =>
'foobar' ],
'foobar' ],
96 $module = $this->getMockBuilder(
'ResourceLoaderWikiModule' )
97 ->setMethods( [
'getTitleInfo',
'getGroup' ] )
99 $module->expects( $this->any() )
100 ->method(
'getTitleInfo' )
101 ->will( $this->returnValue( $titleInfo ) );
102 $module->expects( $this->any() )
103 ->method(
'getGroup' )
104 ->will( $this->returnValue( $group ) );
105 $context = $this->getMockBuilder(
'ResourceLoaderContext' )
106 ->disableOriginalConstructor()
108 $this->assertEquals( $expected, $module->isKnownEmpty(
$context ) );
114 [ [],
'test1',
true ],
117 [
'MediaWiki:Common.js' => [
'page_len' => 1234 ] ],
123 [
'MediaWiki:Foo.js' => [
'page_len' => 0 ] ],
129 [
'User:Example/common.js' => [
'page_len' => 25 ] ],
135 [
'User:Example/foo.js' => [
'page_len' => 0 ] ],
147 'MediaWiki:Common.css' => [
'type' =>
'styles' ],
148 'mediawiki: fallback.css' => [
'type' =>
'styles' ],
151 'MediaWiki:Common.css' => [
'page_len' => 1234 ],
152 'MediaWiki:Fallback.css' => [
'page_len' => 0 ],
154 $expected = $titleInfo;
156 $module = $this->getMockBuilder(
'TestResourceLoaderWikiModule' )
157 ->setMethods( [
'getPages' ] )
159 $module->method(
'getPages' )->willReturn( $pages );
161 $module::$returnFetchTitleInfo = $titleInfo;
163 $context = $this->getMockBuilder(
'ResourceLoaderContext' )
164 ->disableOriginalConstructor()
168 $this->assertEquals( $expected, $module->getTitleInfo(
$context ),
'Title info' );
178 'MediaWiki:Common.css' => [
'type' =>
'styles' ],
183 'mediawiki: fallback.css' => [
'type' =>
'styles' ],
186 'MediaWiki:Common.css' => [
'page_len' => 1234 ],
187 'MediaWiki:Fallback.css' => [
'page_len' => 0 ],
189 $expected = $titleInfo;
191 $module = $this->getMockBuilder(
'TestResourceLoaderWikiModule' )
192 ->setMethods( [
'getPages' ] )
194 $module->method(
'getPages' )->willReturn( $pages );
196 $module::$returnFetchTitleInfo = $titleInfo;
199 $rl->register(
'testmodule', $module );
215 $this->assertEquals( $expected, $module->getTitleInfo(
$context ),
'Title info' );
222 $ret = self::$returnFetchTitleInfo;
223 self::$returnFetchTitleInfo = null;
Abstraction for ResourceLoader modules which pull from wiki pages.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
the array() calling protocol came about after MediaWiki 1.4rc1.
testGetPages($params, Config $config, $expected)
provideGetPages ResourceLoaderWikiModule::getPages
static newDummyContext()
Return a dummy ResourceLoaderContext object suitable for passing into things that don't "really" need...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
static provideConstructor()
static $returnFetchTitleInfo
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
static preloadTitleInfo(ResourceLoaderContext $context, IDatabase $db, array $moduleNames)
static provideIsKnownEmpty()
static fetchTitleInfo(IDatabase $db, array $pages, $fname=null)
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
testGetPreloadedTitleInfo()
ResourceLoaderWikiModule::getTitleInfo ResourceLoaderWikiModule::setTitleInfo ResourceLoaderWikiModul...
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $wikiId)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
testGetTitleInfo()
ResourceLoaderWikiModule::getTitleInfo.
testConstructor($params)
ResourceLoaderWikiModule::__construct provideConstructor.
static newFromObject($object)
Return the same object, without access restrictions.
testGetGroup($params, $expected)
ResourceLoaderWikiModule::getGroup provideGetGroup.
A Config instance which stores all settings as a member variable.
testIsKnownEmpty($titleInfo, $group, $expected)
ResourceLoaderWikiModule::isKnownEmpty provideIsKnownEmpty.
Basic database interface for live and lazy-loaded relation database handles.
Object passed around to modules which contains information about the state of a specific loader reque...