Merge "UserTest: Don't rely on the behavior of unknown user options"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
1 <?php
2
3 /**
4 * @group Title
5 */
6 class TitleTest extends MediaWikiTestCase {
7 protected function setUp() {
8 parent::setUp();
9
10 $this->setMwGlobals( array(
11 'wgLanguageCode' => 'en',
12 'wgContLang' => Language::factory( 'en' ),
13 // User language
14 'wgLang' => Language::factory( 'en' ),
15 'wgAllowUserJs' => false,
16 'wgDefaultLanguageVariant' => false,
17 ) );
18 }
19
20 /**
21 * @covers Title::legalChars
22 */
23 public function testLegalChars() {
24 $titlechars = Title::legalChars();
25
26 foreach ( range( 1, 255 ) as $num ) {
27 $chr = chr( $num );
28 if ( strpos( "#[]{}<>|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) {
29 $this->assertFalse(
30 (bool)preg_match( "/[$titlechars]/", $chr ),
31 "chr($num) = $chr is not a valid titlechar"
32 );
33 } else {
34 $this->assertTrue(
35 (bool)preg_match( "/[$titlechars]/", $chr ),
36 "chr($num) = $chr is a valid titlechar"
37 );
38 }
39 }
40 }
41
42 public static function provideValidSecureAndSplit() {
43 return array(
44 array( 'Sandbox' ),
45 array( 'A "B"' ),
46 array( 'A \'B\'' ),
47 array( '.com' ),
48 array( '~' ),
49 array( '#' ),
50 array( '"' ),
51 array( '\'' ),
52 array( 'Talk:Sandbox' ),
53 array( 'Talk:Foo:Sandbox' ),
54 array( 'File:Example.svg' ),
55 array( 'File_talk:Example.svg' ),
56 array( 'Foo/.../Sandbox' ),
57 array( 'Sandbox/...' ),
58 array( 'A~~' ),
59 array( ':A' ),
60 // Length is 256 total, but only title part matters
61 array( 'Category:' . str_repeat( 'x', 248 ) ),
62 array( str_repeat( 'x', 252 ) ),
63 // interwiki prefix
64 array( 'localtestiw: #anchor' ),
65 array( 'localtestiw:' ),
66 array( 'localtestiw:foo' ),
67 array( 'localtestiw: foo # anchor' ),
68 array( 'localtestiw: Talk: Sandbox # anchor' ),
69 array( 'remotetestiw:' ),
70 array( 'remotetestiw: Talk: # anchor' ),
71 array( 'remotetestiw: #bar' ),
72 array( 'remotetestiw: Talk:' ),
73 array( 'remotetestiw: Talk: Foo' ),
74 array( 'localtestiw:remotetestiw:' ),
75 array( 'localtestiw:remotetestiw:foo' )
76 );
77 }
78
79 public static function provideInvalidSecureAndSplit() {
80 return array(
81 array( '' ),
82 array( ':' ),
83 array( '__ __' ),
84 array( ' __ ' ),
85 // Bad characters forbidden regardless of wgLegalTitleChars
86 array( 'A [ B' ),
87 array( 'A ] B' ),
88 array( 'A { B' ),
89 array( 'A } B' ),
90 array( 'A < B' ),
91 array( 'A > B' ),
92 array( 'A | B' ),
93 // URL encoding
94 array( 'A%20B' ),
95 array( 'A%23B' ),
96 array( 'A%2523B' ),
97 // XML/HTML character entity references
98 // Note: Commented out because they are not marked invalid by the PHP test as
99 // Title::newFromText runs Sanitizer::decodeCharReferencesAndNormalize first.
100 //'A &eacute; B',
101 //'A &#233; B',
102 //'A &#x00E9; B',
103 // Subject of NS_TALK does not roundtrip to NS_MAIN
104 array( 'Talk:File:Example.svg' ),
105 // Directory navigation
106 array( '.' ),
107 array( '..' ),
108 array( './Sandbox' ),
109 array( '../Sandbox' ),
110 array( 'Foo/./Sandbox' ),
111 array( 'Foo/../Sandbox' ),
112 array( 'Sandbox/.' ),
113 array( 'Sandbox/..' ),
114 // Tilde
115 array( 'A ~~~ Name' ),
116 array( 'A ~~~~ Signature' ),
117 array( 'A ~~~~~ Timestamp' ),
118 array( str_repeat( 'x', 256 ) ),
119 // Namespace prefix without actual title
120 array( 'Talk:' ),
121 array( 'Talk:#' ),
122 array( 'Category: ' ),
123 array( 'Category: #bar' ),
124 // interwiki prefix
125 array( 'localtestiw: Talk: # anchor' ),
126 array( 'localtestiw: Talk:' )
127 );
128 }
129
130 private function secureAndSplitGlobals() {
131 $this->setMwGlobals( array(
132 'wgLocalInterwikis' => array( 'localtestiw' ),
133 'wgHooks' => array(
134 'InterwikiLoadPrefix' => array(
135 function ( $prefix, &$data ) {
136 if ( $prefix === 'localtestiw' ) {
137 $data = array( 'iw_url' => 'localtestiw' );
138 } elseif ( $prefix === 'remotetestiw' ) {
139 $data = array( 'iw_url' => 'remotetestiw' );
140 }
141 return false;
142 }
143 )
144 )
145 ));
146 }
147
148 /**
149 * See also mediawiki.Title.test.js
150 * @covers Title::secureAndSplit
151 * @dataProvider provideValidSecureAndSplit
152 * @note This mainly tests MediaWikiTitleCodec::parseTitle().
153 */
154 public function testSecureAndSplitValid( $text ) {
155 $this->secureAndSplitGlobals();
156 $this->assertInstanceOf( 'Title', Title::newFromText( $text ), "Valid: $text" );
157 }
158
159 /**
160 * See also mediawiki.Title.test.js
161 * @covers Title::secureAndSplit
162 * @dataProvider provideInvalidSecureAndSplit
163 * @note This mainly tests MediaWikiTitleCodec::parseTitle().
164 */
165 public function testSecureAndSplitInvalid( $text ) {
166 $this->secureAndSplitGlobals();
167 $this->assertNull( Title::newFromText( $text ), "Invalid: $text" );
168 }
169
170 public static function provideConvertByteClassToUnicodeClass() {
171 return array(
172 array(
173 ' %!"$&\'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+',
174 ' %!"$&\'()*,\\-./0-9:;=?@A-Z\\\\\\^_`a-z~+\\u0080-\\uFFFF',
175 ),
176 array(
177 'QWERTYf-\\xFF+',
178 'QWERTYf-\\x7F+\\u0080-\\uFFFF',
179 ),
180 array(
181 'QWERTY\\x66-\\xFD+',
182 'QWERTYf-\\x7F+\\u0080-\\uFFFF',
183 ),
184 array(
185 'QWERTYf-y+',
186 'QWERTYf-y+',
187 ),
188 array(
189 'QWERTYf-\\x80+',
190 'QWERTYf-\\x7F+\\u0080-\\uFFFF',
191 ),
192 array(
193 'QWERTY\\x66-\\x80+\\x23',
194 'QWERTYf-\\x7F+#\\u0080-\\uFFFF',
195 ),
196 array(
197 'QWERTY\\x66-\\x80+\\xD3',
198 'QWERTYf-\\x7F+\\u0080-\\uFFFF',
199 ),
200 array(
201 '\\\\\\x99',
202 '\\\\\\u0080-\\uFFFF',
203 ),
204 array(
205 '-\\x99',
206 '\\-\\u0080-\\uFFFF',
207 ),
208 array(
209 'QWERTY\\-\\x99',
210 'QWERTY\\-\\u0080-\\uFFFF',
211 ),
212 array(
213 '\\\\x99',
214 '\\\\x99',
215 ),
216 array(
217 'A-\\x9F',
218 'A-\\x7F\\u0080-\\uFFFF',
219 ),
220 array(
221 '\\x66-\\x77QWERTY\\x88-\\x91FXZ',
222 'f-wQWERTYFXZ\\u0080-\\uFFFF',
223 ),
224 array(
225 '\\x66-\\x99QWERTY\\xAA-\\xEEFXZ',
226 'f-\\x7FQWERTYFXZ\\u0080-\\uFFFF',
227 ),
228 );
229 }
230
231 /**
232 * @dataProvider provideConvertByteClassToUnicodeClass
233 * @covers Title::convertByteClassToUnicodeClass
234 */
235 public function testConvertByteClassToUnicodeClass( $byteClass, $unicodeClass ) {
236 $this->assertEquals( $unicodeClass, Title::convertByteClassToUnicodeClass( $byteClass ) );
237 }
238
239 /**
240 * @dataProvider provideSpecialNamesWithAndWithoutParameter
241 * @covers Title::fixSpecialName
242 */
243 public function testFixSpecialNameRetainsParameter( $text, $expectedParam ) {
244 $title = Title::newFromText( $text );
245 $fixed = $title->fixSpecialName();
246 $stuff = explode( '/', $fixed->getDBkey(), 2 );
247 if ( count( $stuff ) == 2 ) {
248 $par = $stuff[1];
249 } else {
250 $par = null;
251 }
252 $this->assertEquals(
253 $expectedParam,
254 $par,
255 "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter"
256 );
257 }
258
259 public static function provideSpecialNamesWithAndWithoutParameter() {
260 return array(
261 array( 'Special:Version', null ),
262 array( 'Special:Version/', '' ),
263 array( 'Special:Version/param', 'param' ),
264 );
265 }
266
267 /**
268 * Auth-less test of Title::isValidMoveOperation
269 *
270 * @group Database
271 * @param string $source
272 * @param string $target
273 * @param array|string|bool $expected Required error
274 * @dataProvider provideTestIsValidMoveOperation
275 * @covers Title::isValidMoveOperation
276 * @covers Title::validateFileMoveOperation
277 */
278 public function testIsValidMoveOperation( $source, $target, $expected ) {
279 $this->setMwGlobals( 'wgContentHandlerUseDB', false );
280 $title = Title::newFromText( $source );
281 $nt = Title::newFromText( $target );
282 $errors = $title->isValidMoveOperation( $nt, false );
283 if ( $expected === true ) {
284 $this->assertTrue( $errors );
285 } else {
286 $errors = $this->flattenErrorsArray( $errors );
287 foreach ( (array)$expected as $error ) {
288 $this->assertContains( $error, $errors );
289 }
290 }
291 }
292
293 public static function provideTestIsValidMoveOperation() {
294 return array(
295 // for Title::isValidMoveOperation
296 array( 'Some page', '', 'badtitletext' ),
297 array( 'Test', 'Test', 'selfmove' ),
298 array( 'Special:FooBar', 'Test', 'immobile-source-namespace' ),
299 array( 'Test', 'Special:FooBar', 'immobile-target-namespace' ),
300 array( 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ),
301 array( 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ),
302 // for Title::validateFileMoveOperation
303 array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ),
304 );
305 }
306
307 /**
308 * Auth-less test of Title::userCan
309 *
310 * @param array $whitelistRegexp
311 * @param string $source
312 * @param string $action
313 * @param array|string|bool $expected Required error
314 *
315 * @covers Title::checkReadPermissions
316 * @dataProvider dataWgWhitelistReadRegexp
317 */
318 public function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
319 // $wgWhitelistReadRegexp must be an array. Since the provided test cases
320 // usually have only one regex, it is more concise to write the lonely regex
321 // as a string. Thus we cast to an array() to honor $wgWhitelistReadRegexp
322 // type requisite.
323 if ( is_string( $whitelistRegexp ) ) {
324 $whitelistRegexp = array( $whitelistRegexp );
325 }
326
327 $title = Title::newFromDBkey( $source );
328
329 global $wgGroupPermissions;
330 $oldPermissions = $wgGroupPermissions;
331 // Disallow all so we can ensure our regex works
332 $wgGroupPermissions = array();
333 $wgGroupPermissions['*']['read'] = false;
334
335 global $wgWhitelistRead;
336 $oldWhitelist = $wgWhitelistRead;
337 // Undo any LocalSettings explicite whitelists so they won't cause a
338 // failing test to succeed. Set it to some random non sense just
339 // to make sure we properly test Title::checkReadPermissions()
340 $wgWhitelistRead = array( 'some random non sense title' );
341
342 global $wgWhitelistReadRegexp;
343 $oldWhitelistRegexp = $wgWhitelistReadRegexp;
344 $wgWhitelistReadRegexp = $whitelistRegexp;
345
346 // Just use $wgUser which in test is a user object for '127.0.0.1'
347 global $wgUser;
348 // Invalidate user rights cache to take in account $wgGroupPermissions
349 // change above.
350 $wgUser->clearInstanceCache();
351 $errors = $title->userCan( $action, $wgUser );
352
353 // Restore globals
354 $wgGroupPermissions = $oldPermissions;
355 $wgWhitelistRead = $oldWhitelist;
356 $wgWhitelistReadRegexp = $oldWhitelistRegexp;
357
358 if ( is_bool( $expected ) ) {
359 # Forge the assertion message depending on the assertion expectation
360 $allowableness = $expected
361 ? " should be allowed"
362 : " should NOT be allowed";
363 $this->assertEquals(
364 $expected,
365 $errors,
366 "User action '$action' on [[$source]] $allowableness."
367 );
368 } else {
369 $errors = $this->flattenErrorsArray( $errors );
370 foreach ( (array)$expected as $error ) {
371 $this->assertContains( $error, $errors );
372 }
373 }
374 }
375
376 /**
377 * Provides test parameter values for testWgWhitelistReadRegexp()
378 */
379 public function dataWgWhitelistReadRegexp() {
380 $ALLOWED = true;
381 $DISALLOWED = false;
382
383 return array(
384 // Everything, if this doesn't work, we're really in trouble
385 array( '/.*/', 'Main_Page', 'read', $ALLOWED ),
386 array( '/.*/', 'Main_Page', 'edit', $DISALLOWED ),
387
388 // We validate against the title name, not the db key
389 array( '/^Main_Page$/', 'Main_Page', 'read', $DISALLOWED ),
390 // Main page
391 array( '/^Main/', 'Main_Page', 'read', $ALLOWED ),
392 array( '/^Main.*/', 'Main_Page', 'read', $ALLOWED ),
393 // With spaces
394 array( '/Mic\sCheck/', 'Mic Check', 'read', $ALLOWED ),
395 // Unicode multibyte
396 // ...without unicode modifier
397 array( '/Unicode Test . Yes/', 'Unicode Test Ñ Yes', 'read', $DISALLOWED ),
398 // ...with unicode modifier
399 array( '/Unicode Test . Yes/u', 'Unicode Test Ñ Yes', 'read', $ALLOWED ),
400 // Case insensitive
401 array( '/MiC ChEcK/', 'mic check', 'read', $DISALLOWED ),
402 array( '/MiC ChEcK/i', 'mic check', 'read', $ALLOWED ),
403
404 // From DefaultSettings.php:
405 array( "@^UsEr.*@i", 'User is banned', 'read', $ALLOWED ),
406 array( "@^UsEr.*@i", 'User:John Doe', 'read', $ALLOWED ),
407
408 // With namespaces:
409 array( '/^Special:NewPages$/', 'Special:NewPages', 'read', $ALLOWED ),
410 array( null, 'Special:Newpages', 'read', $DISALLOWED ),
411
412 );
413 }
414
415 public function flattenErrorsArray( $errors ) {
416 $result = array();
417 foreach ( $errors as $error ) {
418 $result[] = $error[0];
419 }
420
421 return $result;
422 }
423
424 /**
425 * @dataProvider provideGetPageViewLanguage
426 * @covers Title::getPageViewLanguage
427 */
428 public function testGetPageViewLanguage( $expected, $titleText, $contLang,
429 $lang, $variant, $msg = ''
430 ) {
431 global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs;
432
433 // Setup environnement for this test
434 $wgLanguageCode = $contLang;
435 $wgContLang = Language::factory( $contLang );
436 $wgLang = Language::factory( $lang );
437 $wgDefaultLanguageVariant = $variant;
438 $wgAllowUserJs = true;
439
440 $title = Title::newFromText( $titleText );
441 $this->assertInstanceOf( 'Title', $title,
442 "Test must be passed a valid title text, you gave '$titleText'"
443 );
444 $this->assertEquals( $expected,
445 $title->getPageViewLanguage()->getCode(),
446 $msg
447 );
448 }
449
450 public static function provideGetPageViewLanguage() {
451 # Format:
452 # - expected
453 # - Title name
454 # - wgContLang (expected in most case)
455 # - wgLang (on some specific pages)
456 # - wgDefaultLanguageVariant
457 # - Optional message
458 return array(
459 array( 'fr', 'Help:I_need_somebody', 'fr', 'fr', false ),
460 array( 'es', 'Help:I_need_somebody', 'es', 'zh-tw', false ),
461 array( 'zh', 'Help:I_need_somebody', 'zh', 'zh-tw', false ),
462
463 array( 'es', 'Help:I_need_somebody', 'es', 'zh-tw', 'zh-cn' ),
464 array( 'es', 'MediaWiki:About', 'es', 'zh-tw', 'zh-cn' ),
465 array( 'es', 'MediaWiki:About/', 'es', 'zh-tw', 'zh-cn' ),
466 array( 'de', 'MediaWiki:About/de', 'es', 'zh-tw', 'zh-cn' ),
467 array( 'en', 'MediaWiki:Common.js', 'es', 'zh-tw', 'zh-cn' ),
468 array( 'en', 'MediaWiki:Common.css', 'es', 'zh-tw', 'zh-cn' ),
469 array( 'en', 'User:JohnDoe/Common.js', 'es', 'zh-tw', 'zh-cn' ),
470 array( 'en', 'User:JohnDoe/Monobook.css', 'es', 'zh-tw', 'zh-cn' ),
471
472 array( 'zh-cn', 'Help:I_need_somebody', 'zh', 'zh-tw', 'zh-cn' ),
473 array( 'zh', 'MediaWiki:About', 'zh', 'zh-tw', 'zh-cn' ),
474 array( 'zh', 'MediaWiki:About/', 'zh', 'zh-tw', 'zh-cn' ),
475 array( 'de', 'MediaWiki:About/de', 'zh', 'zh-tw', 'zh-cn' ),
476 array( 'zh-cn', 'MediaWiki:About/zh-cn', 'zh', 'zh-tw', 'zh-cn' ),
477 array( 'zh-tw', 'MediaWiki:About/zh-tw', 'zh', 'zh-tw', 'zh-cn' ),
478 array( 'en', 'MediaWiki:Common.js', 'zh', 'zh-tw', 'zh-cn' ),
479 array( 'en', 'MediaWiki:Common.css', 'zh', 'zh-tw', 'zh-cn' ),
480 array( 'en', 'User:JohnDoe/Common.js', 'zh', 'zh-tw', 'zh-cn' ),
481 array( 'en', 'User:JohnDoe/Monobook.css', 'zh', 'zh-tw', 'zh-cn' ),
482
483 array( 'zh-tw', 'Special:NewPages', 'es', 'zh-tw', 'zh-cn' ),
484 array( 'zh-tw', 'Special:NewPages', 'zh', 'zh-tw', 'zh-cn' ),
485
486 );
487 }
488
489 /**
490 * @dataProvider provideBaseTitleCases
491 * @covers Title::getBaseText
492 */
493 public function testGetBaseText( $title, $expected, $msg = '' ) {
494 $title = Title::newFromText( $title );
495 $this->assertEquals( $expected,
496 $title->getBaseText(),
497 $msg
498 );
499 }
500
501 public static function provideBaseTitleCases() {
502 return array(
503 # Title, expected base, optional message
504 array( 'User:John_Doe/subOne/subTwo', 'John Doe/subOne' ),
505 array( 'User:Foo/Bar/Baz', 'Foo/Bar' ),
506 );
507 }
508
509 /**
510 * @dataProvider provideRootTitleCases
511 * @covers Title::getRootText
512 */
513 public function testGetRootText( $title, $expected, $msg = '' ) {
514 $title = Title::newFromText( $title );
515 $this->assertEquals( $expected,
516 $title->getRootText(),
517 $msg
518 );
519 }
520
521 public static function provideRootTitleCases() {
522 return array(
523 # Title, expected base, optional message
524 array( 'User:John_Doe/subOne/subTwo', 'John Doe' ),
525 array( 'User:Foo/Bar/Baz', 'Foo' ),
526 );
527 }
528
529 /**
530 * @todo Handle $wgNamespacesWithSubpages cases
531 * @dataProvider provideSubpageTitleCases
532 * @covers Title::getSubpageText
533 */
534 public function testGetSubpageText( $title, $expected, $msg = '' ) {
535 $title = Title::newFromText( $title );
536 $this->assertEquals( $expected,
537 $title->getSubpageText(),
538 $msg
539 );
540 }
541
542 public static function provideSubpageTitleCases() {
543 return array(
544 # Title, expected base, optional message
545 array( 'User:John_Doe/subOne/subTwo', 'subTwo' ),
546 array( 'User:John_Doe/subOne', 'subOne' ),
547 );
548 }
549
550 public static function provideNewFromTitleValue() {
551 return array(
552 array( new TitleValue( NS_MAIN, 'Foo' ) ),
553 array( new TitleValue( NS_MAIN, 'Foo', 'bar' ) ),
554 array( new TitleValue( NS_USER, 'Hansi_Maier' ) ),
555 );
556 }
557
558 /**
559 * @dataProvider provideNewFromTitleValue
560 */
561 public function testNewFromTitleValue( TitleValue $value ) {
562 $title = Title::newFromTitleValue( $value );
563
564 $dbkey = str_replace( ' ', '_', $value->getText() );
565 $this->assertEquals( $dbkey, $title->getDBkey() );
566 $this->assertEquals( $value->getNamespace(), $title->getNamespace() );
567 $this->assertEquals( $value->getFragment(), $title->getFragment() );
568 }
569
570 public static function provideGetTitleValue() {
571 return array(
572 array( 'Foo' ),
573 array( 'Foo#bar' ),
574 array( 'User:Hansi_Maier' ),
575 );
576 }
577
578 /**
579 * @dataProvider provideGetTitleValue
580 */
581 public function testGetTitleValue( $text ) {
582 $title = Title::newFromText( $text );
583 $value = $title->getTitleValue();
584
585 $dbkey = str_replace( ' ', '_', $value->getText() );
586 $this->assertEquals( $title->getDBkey(), $dbkey );
587 $this->assertEquals( $title->getNamespace(), $value->getNamespace() );
588 $this->assertEquals( $title->getFragment(), $value->getFragment() );
589 }
590
591 public static function provideGetFragment() {
592 return array(
593 array( 'Foo', '' ),
594 array( 'Foo#bar', 'bar' ),
595 array( 'Foo#bär', 'bär' ),
596
597 // Inner whitespace is normalized
598 array( 'Foo#bar_bar', 'bar bar' ),
599 array( 'Foo#bar bar', 'bar bar' ),
600 array( 'Foo#bar bar', 'bar bar' ),
601
602 // Leading whitespace is kept, trailing whitespace is trimmed.
603 // XXX: Is this really want we want?
604 array( 'Foo#_bar_bar_', ' bar bar' ),
605 array( 'Foo# bar bar ', ' bar bar' ),
606 );
607 }
608
609 /**
610 * @dataProvider provideGetFragment
611 *
612 * @param string $full
613 * @param string $fragment
614 */
615 public function testGetFragment( $full, $fragment ) {
616 $title = Title::newFromText( $full );
617 $this->assertEquals( $fragment, $title->getFragment() );
618 }
619
620 /**
621 * @covers Title::isAlwaysKnown
622 * @dataProvider provideIsAlwaysKnown
623 * @param string $page
624 * @param bool $isKnown
625 */
626 public function testIsAlwaysKnown( $page, $isKnown ) {
627 $title = Title::newFromText( $page );
628 $this->assertEquals( $isKnown, $title->isAlwaysKnown() );
629 }
630
631 public static function provideIsAlwaysKnown() {
632 return array(
633 array( 'Some nonexistent page', false ),
634 array( 'UTPage', false ),
635 array( '#test', true ),
636 array( 'Special:BlankPage', true ),
637 array( 'Special:SomeNonexistentSpecialPage', false ),
638 array( 'MediaWiki:Parentheses', true ),
639 array( 'MediaWiki:Some nonexistent message', false ),
640 );
641 }
642
643 /**
644 * @covers Title::isAlwaysKnown
645 */
646 public function testIsAlwaysKnownOnInterwiki() {
647 $title = Title::makeTitle( NS_MAIN, 'Interwiki link', '', 'externalwiki' );
648 $this->assertTrue( $title->isAlwaysKnown() );
649 }
650 }