35 'wgAllowUserJs' =>
false,
36 'wgDefaultLanguageVariant' =>
false,
37 'wgMetaNamespace' =>
'Project',
38 'wgLocalInterwikis' => [
'localtestiw' ],
39 'wgCapitalLinks' =>
true,
44 'InterwikiLoadPrefix' => [
45 function ( $prefix, &$data ) {
46 if ( $prefix ===
'localtestiw' ) {
47 $data = [
'iw_url' =>
'localtestiw' ];
48 } elseif ( $prefix ===
'remotetestiw' ) {
49 $data = [
'iw_url' =>
'remotetestiw' ];
67 $genderCache = $this->getMockBuilder( GenderCache::class )
68 ->disableOriginalConstructor()
71 $genderCache->expects( $this->any() )
72 ->method(
'getGenderOf' )
73 ->will( $this->returnCallback(
function ( $userName ) {
74 return preg_match(
'/^[^- _]+a( |_|$)/u', $userName ) ?
'female' :
'male';
84 $lang->resetNamespaces();
90 [
NS_MAIN,
'Foo_Bar',
'',
'',
'en',
'Foo Bar' ],
91 [
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'',
'en',
'User:Hansi Maier#stuff and so on' ],
92 [
false,
'Hansi_Maier',
'',
'',
'en',
'Hansi Maier' ],
99 'User talk:hansi maier',
100 'User talk:Hansi maier'
105 [
NS_USER,
'Lisa_Müller',
'',
'',
'de',
'Benutzerin:Lisa Müller' ],
106 [
NS_MAIN,
'FooBar',
'',
'remotetestiw',
'en',
'remotetestiw:FooBar' ],
113 public function testFormat( $namespace, $text, $fragment, $interwiki,
$lang, $expected,
116 if ( $normalized ===
null ) {
117 $normalized = $expected;
121 $actual = $codec->formatTitle( $namespace, $text, $fragment, $interwiki );
123 $this->assertEquals( $expected, $actual,
'formatted' );
126 $parsed = $codec->parseTitle( $actual,
NS_MAIN );
127 $actual2 = $codec->formatTitle(
128 $parsed->getNamespace(),
130 $parsed->getFragment(),
131 $parsed->getInterwiki()
134 $this->assertEquals( $normalized, $actual2,
'normalized after round trip' );
139 [
NS_MAIN,
'Foo_Bar',
'',
'en',
'Foo Bar' ],
140 [
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'Hansi Maier' ],
151 $actual = $codec->getText(
$title );
153 $this->assertEquals( $expected, $actual );
158 [
NS_MAIN,
'Foo_Bar',
'',
'en',
'Foo Bar' ],
159 [
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'User:Hansi Maier' ],
162 [
NS_USER_TALK,
'hansi__maier',
'',
'en',
'User talk:hansi maier' ],
166 [
NS_USER,
'Lisa_Müller',
'',
'de',
'Benutzerin:Lisa Müller' ],
167 [ 1000000,
'Invalid_namespace',
'',
'en',
'Special:Badtitle/NS1000000:Invalid namespace' ],
178 $actual = $codec->getPrefixedText(
$title );
180 $this->assertEquals( $expected, $actual );
185 [
NS_MAIN,
'Foo_Bar',
'',
'',
'en',
'Foo_Bar' ],
186 [
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'',
'en',
'User:Hansi_Maier' ],
189 [
NS_USER_TALK,
'hansi__maier',
'',
'',
'en',
'User_talk:hansi__maier' ],
193 [
NS_USER,
'Lisa_Müller',
'',
'',
'de',
'Benutzerin:Lisa_Müller' ],
195 [
NS_MAIN,
'Remote_page',
'',
'remotetestiw',
'en',
'remotetestiw:Remote_page' ],
198 [ 10000000,
'Foobar',
'',
'',
'en',
'Special:Badtitle/NS10000000:Foobar' ],
206 $interwiki,
$lang, $expected
211 $actual = $codec->getPrefixedDBkey(
$title );
213 $this->assertEquals( $expected, $actual );
218 [
NS_MAIN,
'Foo_Bar',
'',
'en',
'Foo Bar' ],
219 [
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'User:Hansi Maier#stuff and so on' ],
222 [
NS_USER_TALK,
'hansi__maier',
'',
'en',
'User talk:hansi maier' ],
233 $actual = $codec->getFullText(
$title );
235 $this->assertEquals( $expected, $actual );
243 [
' : Hansi_Maier _ ',
NS_MAIN,
'en',
247 [
' lisa Müller',
NS_USER,
'de',
249 [
'benutzerin:lisa Müller#stuff',
NS_MAIN,
'de',
252 [
':Category:Quux',
NS_MAIN,
'en',
254 [
'Category:Quux',
NS_MAIN,
'en',
270 [
' _ Foo __ Bar_ _',
NS_MAIN,
'en',
282 [
'Talk:Sandbox',
NS_MAIN,
'en',
284 [
'Talk:Foo:Sandbox',
NS_MAIN,
'en',
286 [
'File:Example.svg',
NS_MAIN,
'en',
288 [
'File_talk:Example.svg',
NS_MAIN,
'en',
290 [
'Foo/.../Sandbox',
NS_MAIN,
'en',
292 [
'Sandbox/...',
NS_MAIN,
'en',
297 [
'Category:' . str_repeat(
'x', 248 ),
NS_MAIN,
'en',
299 'X' . str_repeat(
'x', 247 ) ) ],
300 [ str_repeat(
'x', 252 ),
NS_MAIN,
'en',
301 'X' . str_repeat(
'x', 251 ) ]
310 $title = str_replace(
' ',
'_', trim( $text ) );
313 if ( is_string(
$title ) ) {
318 $actual = $codec->parseTitle( $text, $ns );
320 $this->assertEquals(
$title, $actual );
333 [
'Talk:File:Foo.jpg' ],
334 [
'Talk:localtestiw:Foo' ],
362 [
'Talk:File:Example.svg' ],
369 [
'Foo/../Sandbox' ],
374 [
'A ~~~~ Signature' ],
375 [
'A ~~~~~ Timestamp' ],
376 [ str_repeat(
'x', 256 ) ],
388 $this->setExpectedException( MalformedTitleException::class );
391 $codec->parseTitle( $text,
NS_MAIN );
397 [
NS_USER,
'Foo',
'en',
'User' ],
398 [
NS_USER,
'Hansi Maier',
'de',
'Benutzer' ],
402 [
NS_USER,
'Lisa Müller',
'de',
'Benutzerin' ],
411 $name = $codec->getNamespaceName( $namespace, $text );
413 $this->assertEquals( $expected,
$name );
Represents a page (or page fragment) title within MediaWiki.
namespace and then decline to actually register it file or subcat img or subcat $title
Allows to change the fields on the form that will be generated $name
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(!isset( $args[0])) $lang