18 'wgContentNamespaces' => [
NS_MAIN ],
19 'wgNamespacesWithSubpages' => [
24 'wgCapitalLinks' =>
true,
25 'wgCapitalLinkOverrides' => [],
26 'wgNonincludableNamespaces' => [],
30# ### START OF TESTS #########################################################
37 $this->assertFalse( MWNamespace::isMovable(
NS_SPECIAL ) );
38 # @todo FIXME: Write more tests!!
51 $this->assertIsSubject(
NS_MAIN );
52 $this->assertIsSubject( NS_USER );
53 $this->assertIsSubject( 100 ); # user defined
56 $this->assertIsNotSubject(
NS_TALK );
58 $this->assertIsNotSubject( 101 ); # user defined
72 $this->assertIsNotTalk(
NS_MAIN );
73 $this->assertIsNotTalk( NS_USER );
74 $this->assertIsNotTalk( 100 ); # user defined
79 $this->assertIsTalk( 101 ); # user defined
90 $this->assertEquals(
NS_MAIN, MWNamespace::getSubject(
NS_TALK ) );
91 $this->assertEquals( NS_USER, MWNamespace::getSubject(
NS_USER_TALK ) );
103 $this->assertEquals(
NS_USER_TALK, MWNamespace::getTalk( NS_USER ) );
114 $this->assertNull( MWNamespace::getTalk(
NS_MEDIA ) );
124 $this->assertNull( MWNamespace::getTalk(
NS_SPECIAL ) );
134 $this->assertEquals(
NS_TALK, MWNamespace::getAssociated(
NS_MAIN ) );
135 $this->assertEquals(
NS_MAIN, MWNamespace::getAssociated(
NS_TALK ) );
138 # ## Exceptions with getAssociated()
139 # ## NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
140 # ## an exception for them.
146 $this->assertNull( MWNamespace::getAssociated(
NS_MEDIA ) );
154 $this->assertNull( MWNamespace::getAssociated(
NS_SPECIAL ) );
178 $this->assertTrue( MWNamespace::equals(
NS_MAIN, 0 ) );
179 $this->assertTrue( MWNamespace::equals( NS_USER, NS_USER ) );
180 $this->assertTrue( MWNamespace::equals( NS_USER, 2 ) );
184 $this->assertFalse( MWNamespace::equals( NS_USER,
NS_USER_TALK ) );
211 "NS_MEDIA and NS_SPECIAL are different subject namespaces"
215 "NS_SPECIAL and NS_MEDIA are different subject namespaces"
288 $actual = MWNamespace::hasTalkNamespace( $index );
289 $this->assertSame( $actual, $expected,
"NS $index" );
300 $actual = MWNamespace::canTalk( $index );
301 $this->assertSame( $actual, $expected,
"NS $index" );
311 $this->assertIsContent(
NS_MAIN );
315 $this->assertIsNotContent(
NS_MEDIA );
317 $this->assertIsNotContent(
NS_TALK );
318 $this->assertIsNotContent( NS_USER );
320 $this->assertIsNotContent( 100 );
332 $this->assertIsNotContent( 252 );
337 $this->assertIsContent( 252 );
340 $this->assertIsContent(
NS_MAIN );
348 $this->assertIsNotWatchable(
NS_MEDIA );
352 $this->assertIsWatchable(
NS_MAIN );
353 $this->assertIsWatchable(
NS_TALK );
356 $this->assertIsWatchable( 100 );
357 $this->assertIsWatchable( 101 );
367 $this->assertHasNotSubpages(
NS_MEDIA );
371 $this->assertHasNotSubpages(
NS_MAIN );
374 $this->assertHasSubpages(
NS_MAIN );
377 $this->assertHasNotSubpages(
NS_MAIN );
380 $this->assertHasSubpages(
NS_TALK );
381 $this->assertHasSubpages( NS_USER );
393 MWNamespace::getContentNamespaces(),
394 '$wgContentNamespaces is an array with only NS_MAIN by default'
397 # test !is_array( $wgcontentNamespaces )
399 $this->assertEquals( [
NS_MAIN ], MWNamespace::getContentNamespaces() );
402 $this->assertEquals( [
NS_MAIN ], MWNamespace::getContentNamespaces() );
405 $this->assertEquals( [
NS_MAIN ], MWNamespace::getContentNamespaces() );
408 $this->assertEquals( [
NS_MAIN ], MWNamespace::getContentNamespaces() );
410 # test $wgContentNamespaces === []
412 $this->assertEquals( [
NS_MAIN ], MWNamespace::getContentNamespaces() );
414 # test !in_array( NS_MAIN, $wgContentNamespaces )
418 MWNamespace::getContentNamespaces(),
419 'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
422 # test other cases, return $wgcontentNamespaces as is
426 MWNamespace::getContentNamespaces()
432 MWNamespace::getContentNamespaces()
440 $subjectsNS = MWNamespace::getSubjectNamespaces();
441 $this->assertContains(
NS_MAIN, $subjectsNS,
442 "Talk namespaces should have NS_MAIN" );
443 $this->assertNotContains(
NS_TALK, $subjectsNS,
444 "Talk namespaces should have NS_TALK" );
446 $this->assertNotContains(
NS_MEDIA, $subjectsNS,
447 "Talk namespaces should not have NS_MEDIA" );
448 $this->assertNotContains(
NS_SPECIAL, $subjectsNS,
449 "Talk namespaces should not have NS_SPECIAL" );
456 $talkNS = MWNamespace::getTalkNamespaces();
457 $this->assertContains(
NS_TALK, $talkNS,
458 "Subject namespaces should have NS_TALK" );
459 $this->assertNotContains(
NS_MAIN, $talkNS,
460 "Subject namespaces should not have NS_MAIN" );
462 $this->assertNotContains(
NS_MEDIA, $talkNS,
463 "Subject namespaces should not have NS_MEDIA" );
464 $this->assertNotContains(
NS_SPECIAL, $talkNS,
465 "Subject namespaces should not have NS_SPECIAL" );
476 MWNamespace::isCapitalized(
NS_MEDIA ),
477 MWNamespace::isCapitalized(
NS_FILE ),
478 'NS_MEDIA and NS_FILE have same capitalization rendering'
482 $this->assertIsCapitalized(
NS_MEDIA );
483 $this->assertIsCapitalized(
NS_FILE );
488 $this->assertIsCapitalized( NS_USER );
489 $this->assertIsCapitalized( NS_MEDIAWIKI );
515 $this->assertIsCapitalized( NS_USER );
516 $this->assertIsCapitalized( NS_MEDIAWIKI );
539 $this->assertIsCapitalized( NS_USER );
540 $this->assertIsCapitalized( NS_MEDIAWIKI );
548 $this->assertIsCapitalized( NS_USER );
549 $this->assertIsCapitalized( NS_MEDIAWIKI );
566 $this->assertTrue( MWNamespace::hasGenderDistinction( NS_USER ) );
567 $this->assertTrue( MWNamespace::hasGenderDistinction(
NS_USER_TALK ) );
570 $this->assertFalse( MWNamespace::hasGenderDistinction(
NS_MEDIA ) );
571 $this->assertFalse( MWNamespace::hasGenderDistinction(
NS_SPECIAL ) );
572 $this->assertFalse( MWNamespace::hasGenderDistinction(
NS_MAIN ) );
573 $this->assertFalse( MWNamespace::hasGenderDistinction(
NS_TALK ) );
584 $this->assertTrue( MWNamespace::isNonincludable( NS_USER ) );
585 $this->assertFalse( MWNamespace::isNonincludable(
NS_TEMPLATE ) );
588 # ###### HELPERS ###########################################################
591 if ( method_exists( $this, $method ) ) {
592 return $this->$method(
$args );
596 '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
600 # Interprets arguments:
602 $msg = isset(
$args[1] ) ?
$args[1] :
" dummy message";
604 # Forge the namespace constant name:
606 $ns_name =
"NS_MAIN";
608 $ns_name =
"NS_" . strtoupper( MWNamespace::getCanonicalName( $ns ) );
610 # ... and the MWNamespace method name
611 $nsMethod = strtolower( $m[1] ) . $m[3];
613 $expect = ( $m[2] ===
'' );
614 $expect_name = $expect ?
'TRUE' :
'FALSE';
616 return $this->assertEquals( $expect,
617 MWNamespace::$nsMethod( $ns, $msg ),
618 "MWNamespace::$nsMethod( $ns_name ) should returns $expect_name"
622 throw new Exception( __METHOD__ .
" could not find a method named $method\n" );
626 $this->assertTrue( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
630 $this->assertFalse( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
$wgNamespacesWithSubpages
Which namespaces should support subpages? See Language.php for a list of namespaces.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
$wgNonincludableNamespaces
Pages in namespaces in this array can not be used as templates.
$wgContentNamespaces
Array of namespaces which can be deemed to contain valid "content", as far as the site statistics are...
Test class for MWNamespace.
testHasGenderDistinction()
MWNamespace::hasGenderDistinction.
testGetTalkNamespaces()
MWNamespace::getTalkNamespaces.
assertDifferentSubject( $ns1, $ns2, $msg='')
testGetAssociatedExceptionsForNsSpecial()
MWException MWNamespace::getAssociated.
testSubjectEquals()
MWNamespace::subjectEquals.
testGetTalk()
Regular getTalk() calls Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in the funct...
testHasSubpages()
MWNamespace::hasSubpages.
testHasTalkNamespace( $index, $expected)
provideHasTalkNamespace MWNamespace::hasTalkNamespace
testIsWatchable()
MWNamespace::isWatchable.
testIsContentAdvanced()
Similar to testIsContent() but alters the $wgContentNamespaces global variable.
testGetContentNamespaces()
MWNamespace::getContentNamespaces.
testGetAssociated()
Regular getAssociated() calls Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested...
provideHasTalkNamespace()
testIsCapitalizedWithWgCapitalLinks()
Follows up for testIsCapitalizedHardcodedAssertions() but alter the global $wgCapitalLink setting to ...
testGetTalkExceptionsForNsSpecial()
Exceptions with getTalk() NS_SPECIAL does not have talk pages.
testGetSubject()
MWNamespace::getSubject.
testIsCapitalizedHardcodedAssertions()
Some namespaces are always capitalized per code definition in MWNamespace::$alwaysCapitalizedNamespac...
testGetAssociatedExceptionsForNsMedia()
MWException MWNamespace::getAssociated.
testEquals()
Test MWNamespace::equals Note if we add a namespace registration system with keys like 'MAIN' we shou...
testIsNonincludable()
MWNamespace::isNonincludable.
testGetSubjectNamespaces()
MWNamespace::getSubjectNamespaces.
testIsCapitalizedWithWgCapitalLinkOverrides()
Counter part for MWNamespace::testIsCapitalizedWithWgCapitalLinks() now testing the $wgCapitalLinkOve...
assertSameSubject( $ns1, $ns2, $msg='')
testIsTalk()
Reverse of testIsSubject().
testSpecialAndMediaAreDifferentSubjects()
MWNamespace::subjectEquals.
testCanTalk( $index, $expected)
provideHasTalkNamespace MWNamespace::canTalk
testGetTalkExceptionsForNsMedia()
Exceptions with getTalk() NS_MEDIA does not have talk pages.
testIsContent()
MWNamespace::isContent.
testIsSubject()
Please make sure to change testIsTalk() if you change the assertions below MWNamespace::isSubject.
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
processing should stop and the error should be shown to the user * false