Go to the documentation of this file.
18 'wgContentNamespaces' => [
NS_MAIN ],
19 'wgNamespacesWithSubpages' => [
24 'wgCapitalLinks' =>
true,
25 'wgCapitalLinkOverrides' => [],
26 'wgNonincludableNamespaces' => [],
30 # ### START OF TESTS #########################################################
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
138 # ## Exceptions with getAssociated()
139 # ## NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
140 # ## an exception for them.
211 "NS_MEDIA and NS_SPECIAL are different subject namespaces"
215 "NS_SPECIAL and NS_MEDIA are different subject namespaces"
289 $this->assertSame( $actual, $expected,
"NS $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 );
394 '$wgContentNamespaces is an array with only NS_MAIN by default'
397 # test !is_array( $wgcontentNamespaces )
410 # test $wgContentNamespaces === []
414 # test !in_array( NS_MAIN, $wgContentNamespaces )
419 'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
422 # test other cases, return $wgcontentNamespaces as is
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" );
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" );
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 );
515 $this->assertIsCapitalized(
NS_USER );
539 $this->assertIsCapitalized(
NS_USER );
548 $this->assertIsCapitalized(
NS_USER );
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";
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" );
$wgNonincludableNamespaces
Pages in namespaces in this array can not be used as templates.
testIsContentAdvanced()
Similar to testIsContent() but alters the $wgContentNamespaces global variable.
testSubjectEquals()
MWNamespace::subjectEquals.
static subjectEquals( $ns1, $ns2)
Returns whether the specified namespaces share the same subject.
static isNonincludable( $index)
It is not possible to use pages from this namespace as template?
processing should stop and the error should be shown to the user * false
assertDifferentSubject( $ns1, $ns2, $msg='')
static hasGenderDistinction( $index)
Does the namespace (potentially) have different aliases for different genders.
static getTalkNamespaces()
List all namespace indices which are considered talks, aka not a subject or special namespace.
testGetSubjectNamespaces()
MWNamespace::getSubjectNamespaces.
testGetAssociated()
Regular getAssociated() calls Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested...
testGetContentNamespaces()
MWNamespace::getContentNamespaces.
testHasTalkNamespace( $index, $expected)
provideHasTalkNamespace MWNamespace::hasTalkNamespace
testIsNonincludable()
MWNamespace::isNonincludable.
testIsSubject()
Please make sure to change testIsTalk() if you change the assertions below MWNamespace::isSubject.
provideHasTalkNamespace()
testGetSubject()
MWNamespace::getSubject.
testIsCapitalizedWithWgCapitalLinks()
Follows up for testIsCapitalizedHardcodedAssertions() but alter the global $wgCapitalLink setting to ...
static getSubjectNamespaces()
List all namespace indices which are considered subject, aka not a talk or special namespace.
testSpecialAndMediaAreDifferentSubjects()
MWNamespace::subjectEquals.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
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
testCanTalk( $index, $expected)
provideHasTalkNamespace MWNamespace::canTalk
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Test class for MWNamespace.
static canTalk( $index)
Does this namespace ever have a talk namespace?
testIsTalk()
Reverse of testIsSubject().
static hasTalkNamespace( $index)
Does this namespace ever have a talk namespace?
testGetTalkNamespaces()
MWNamespace::getTalkNamespaces.
testIsWatchable()
MWNamespace::isWatchable.
static isMovable( $index)
Can pages in the given namespace be moved?
when a variable name is used in a it is silently declared as a new masking the global
assertSameSubject( $ns1, $ns2, $msg='')
testEquals()
Test MWNamespace::equals Note if we add a namespace registration system with keys like 'MAIN' we shou...
testGetAssociatedExceptionsForNsMedia()
MWException MWNamespace::getAssociated.
testIsCapitalizedHardcodedAssertions()
Some namespaces are always capitalized per code definition in MWNamespace::$alwaysCapitalizedNamespac...
testGetTalkExceptionsForNsMedia()
Exceptions with getTalk() NS_MEDIA does not have talk pages.
$wgContentNamespaces
Array of namespaces which can be deemed to contain valid "content", as far as the site statistics are...
testIsCapitalizedWithWgCapitalLinkOverrides()
Counter part for MWNamespace::testIsCapitalizedWithWgCapitalLinks() now testing the $wgCapitalLinkOve...
testGetTalkExceptionsForNsSpecial()
Exceptions with getTalk() NS_SPECIAL does not have talk pages.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
static equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
testHasSubpages()
MWNamespace::hasSubpages.
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 getTalk( $index)
Get the talk namespace index for a given namespace.
testGetTalk()
Regular getTalk() calls Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in the funct...
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
$wgNamespacesWithSubpages
Which namespaces should support subpages? See Language.php for a list of namespaces.
testGetAssociatedExceptionsForNsSpecial()
MWException MWNamespace::getAssociated.
testIsContent()
MWNamespace::isContent.
static getAssociated( $index)
Get the associated namespace.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
testHasGenderDistinction()
MWNamespace::hasGenderDistinction.