36 'wgLanguageCode' =>
'en',
40 'wgAllowUserJs' =>
false,
41 'wgDefaultLanguageVariant' =>
false,
42 'wgLocalInterwikis' =>
array(
'localtestiw' ),
47 'InterwikiLoadPrefix' =>
array(
48 function ( $prefix, &$data ) {
49 if ( $prefix ===
'localtestiw' ) {
50 $data =
array(
'iw_url' =>
'localtestiw' );
51 } elseif ( $prefix ===
'remotetestiw' ) {
52 $data =
array(
'iw_url' =>
'remotetestiw' );
68 $genderCache = $this->getMockBuilder(
'GenderCache' )
69 ->disableOriginalConstructor()
72 $genderCache->expects( $this->any() )
73 ->method(
'getGenderOf' )
74 ->will( $this->returnCallback(
function( $userName ) {
75 return preg_match(
'/^[^- _]+a( |_|$)/u', $userName ) ?
'female' :
'male';
90 array(
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'User:Hansi Maier#stuff and so on' ),
91 array(
false,
'Hansi_Maier',
'',
'en',
'Hansi Maier' ),
92 array(
NS_USER_TALK,
'hansi__maier',
'',
'en',
'User talk:hansi maier',
'User talk:Hansi maier' ),
96 array(
NS_USER,
'Lisa_Müller',
'',
'de',
'Benutzerin:Lisa Müller' ),
103 public function testFormat( $namespace, $text, $fragment, $lang, $expected, $normalized =
null ) {
104 if ( $normalized ===
null ) {
105 $normalized = $expected;
109 $actual = $codec->formatTitle( $namespace, $text, $fragment );
111 $this->assertEquals( $expected, $actual,
'formatted' );
114 $parsed = $codec->parseTitle( $actual,
NS_MAIN );
115 $actual2 = $codec->formatTitle( $parsed->getNamespace(), $parsed->getText(), $parsed->getFragment() );
117 $this->assertEquals( $normalized, $actual2,
'normalized after round trip' );
123 array(
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'Hansi Maier' ),
130 public function testGetText( $namespace, $dbkey, $fragment, $lang, $expected ) {
134 $actual = $codec->getText(
$title );
136 $this->assertEquals( $expected, $actual );
142 array(
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'User:Hansi Maier' ),
149 array(
NS_USER,
'Lisa_Müller',
'',
'de',
'Benutzerin:Lisa Müller' ),
160 $actual = $codec->getPrefixedText(
$title );
162 $this->assertEquals( $expected, $actual );
168 array(
NS_USER,
'Hansi_Maier',
'stuff_and_so_on',
'en',
'User:Hansi Maier#stuff and so on' ),
182 $actual = $codec->getFullText(
$title );
184 $this->assertEquals( $expected, $actual );
246 array(
'Category:' . str_repeat(
'x', 248 ),
NS_MAIN,
'en',
248 'X' . str_repeat(
'x', 247 ) ) ),
250 'X' . str_repeat(
'x', 251 ) )
259 $title = str_replace(
' ',
'_', trim( $text ) );
262 if ( is_string(
$title ) ) {
267 $actual = $codec->parseTitle( $text, $ns );
269 $this->assertEquals(
$title, $actual );
282 array(
'Talk:File:Foo.jpg' ),
283 array(
'Talk:localtestiw:Foo' ),
284 array(
'remotetestiw:Foo' ),
312 array(
'Talk:File:Example.svg' ),
316 array(
'./Sandbox' ),
317 array(
'../Sandbox' ),
318 array(
'Foo/./Sandbox' ),
319 array(
'Foo/../Sandbox' ),
320 array(
'Sandbox/.' ),
321 array(
'Sandbox/..' ),
323 array(
'A ~~~ Name' ),
324 array(
'A ~~~~ Signature' ),
325 array(
'A ~~~~~ Timestamp' ),
326 array( str_repeat(
'x', 256 ) ),
329 array(
'Category: ' ),
330 array(
'Category: #bar' )
338 $this->setExpectedException(
'MalformedTitleException' );
341 $codec->parseTitle( $text,
NS_MAIN );
368 $name = $codec->getNamespaceName( $namespace, $text );
370 $this->assertEquals( $expected,
$name );