20 'wgContentNamespaces' => [
NS_MAIN ],
21 'wgNamespacesWithSubpages' => [
26 'wgCapitalLinks' =>
true,
27 'wgCapitalLinkOverrides' => [],
28 'wgNonincludableNamespaces' => [],
32 # ### START OF TESTS #########################################################
40 # @todo FIXME: Write more tests!!
53 $this->assertIsSubject(
NS_MAIN );
54 $this->assertIsSubject(
NS_USER );
55 $this->assertIsSubject( 100 ); #
user defined
58 $this->assertIsNotSubject(
NS_TALK );
60 $this->assertIsNotSubject( 101 ); #
user defined
74 $this->assertIsNotTalk(
NS_MAIN );
75 $this->assertIsNotTalk(
NS_USER );
76 $this->assertIsNotTalk( 100 ); #
user defined
81 $this->assertIsTalk( 101 ); #
user defined
140 # ## Exceptions with getAssociated()
141 # ## NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
142 # ## an exception for them.
213 "NS_MEDIA and NS_SPECIAL are different subject namespaces"
217 "NS_SPECIAL and NS_MEDIA are different subject namespaces"
271 $this->assertCanNotTalk(
NS_MEDIA );
274 $this->assertCanTalk(
NS_MAIN );
275 $this->assertCanTalk(
NS_TALK );
276 $this->assertCanTalk(
NS_USER );
280 $this->assertCanTalk( 100 );
281 $this->assertCanTalk( 101 );
291 $this->assertIsContent(
NS_MAIN );
295 $this->assertIsNotContent(
NS_MEDIA );
297 $this->assertIsNotContent(
NS_TALK );
298 $this->assertIsNotContent(
NS_USER );
300 $this->assertIsNotContent( 100 );
312 $this->assertIsNotContent( 252 );
315 $wgContentNamespaces[] = 252;
317 $this->assertIsContent( 252 );
320 $this->assertIsContent(
NS_MAIN );
328 $this->assertIsNotWatchable(
NS_MEDIA );
332 $this->assertIsWatchable(
NS_MAIN );
333 $this->assertIsWatchable(
NS_TALK );
336 $this->assertIsWatchable( 100 );
337 $this->assertIsWatchable( 101 );
347 $this->assertHasNotSubpages(
NS_MEDIA );
351 $this->assertHasNotSubpages(
NS_MAIN );
353 $wgNamespacesWithSubpages[
NS_MAIN] =
true;
354 $this->assertHasSubpages(
NS_MAIN );
356 $wgNamespacesWithSubpages[
NS_MAIN] =
false;
357 $this->assertHasNotSubpages(
NS_MAIN );
360 $this->assertHasSubpages(
NS_TALK );
361 $this->assertHasSubpages(
NS_USER );
374 '$wgContentNamespaces is an array with only NS_MAIN by default'
377 # test !is_array( $wgcontentNamespaces )
378 $wgContentNamespaces =
'';
381 $wgContentNamespaces =
false;
384 $wgContentNamespaces = null;
387 $wgContentNamespaces = 5;
390 # test $wgContentNamespaces === []
391 $wgContentNamespaces = [];
394 # test !in_array( NS_MAIN, $wgContentNamespaces )
399 'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
402 # test other cases, return $wgcontentNamespaces as is
403 $wgContentNamespaces = [
NS_MAIN ];
421 $this->assertContains(
NS_MAIN, $subjectsNS,
422 "Talk namespaces should have NS_MAIN" );
423 $this->assertNotContains(
NS_TALK, $subjectsNS,
424 "Talk namespaces should have NS_TALK" );
426 $this->assertNotContains(
NS_MEDIA, $subjectsNS,
427 "Talk namespaces should not have NS_MEDIA" );
428 $this->assertNotContains(
NS_SPECIAL, $subjectsNS,
429 "Talk namespaces should not have NS_SPECIAL" );
437 $this->assertContains(
NS_TALK, $talkNS,
438 "Subject namespaces should have NS_TALK" );
439 $this->assertNotContains(
NS_MAIN, $talkNS,
440 "Subject namespaces should not have NS_MAIN" );
442 $this->assertNotContains(
NS_MEDIA, $talkNS,
443 "Subject namespaces should not have NS_MEDIA" );
444 $this->assertNotContains(
NS_SPECIAL, $talkNS,
445 "Subject namespaces should not have NS_SPECIAL" );
458 'NS_MEDIA and NS_FILE have same capitalization rendering'
462 $this->assertIsCapitalized(
NS_MEDIA );
463 $this->assertIsCapitalized(
NS_FILE );
468 $this->assertIsCapitalized(
NS_USER );
491 $wgCapitalLinks =
false;
495 $this->assertIsCapitalized(
NS_USER );
519 $this->assertIsCapitalized(
NS_USER );
524 $wgCapitalLinkOverrides[
NS_USER] =
false;
528 $this->assertIsCapitalized(
NS_USER );
538 $this->assertIsCapitalized( NS_PROJECT );
560 global $wgNonincludableNamespaces;
562 $wgNonincludableNamespaces = [
NS_USER ];
568 # ###### HELPERS ###########################################################
571 if ( method_exists( $this, $method ) ) {
572 return $this->$method(
$args );
576 '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
580 # Interprets arguments:
582 $msg = isset(
$args[1] ) ?
$args[1] :
" dummy message";
584 # Forge the namespace constant name:
586 $ns_name =
"NS_MAIN";
590 # ... and the MWNamespace method name
591 $nsMethod = strtolower( $m[1] ) . $m[3];
593 $expect = ( $m[2] ===
'' );
594 $expect_name = $expect ?
'TRUE' :
'FALSE';
596 return $this->assertEquals( $expect,
597 MWNamespace::$nsMethod( $ns, $msg ),
598 "MWNamespace::$nsMethod( $ns_name ) should returns $expect_name"
602 throw new Exception( __METHOD__ .
" could not find a method named $method\n" );
testSpecialAndMediaAreDifferentSubjects()
MWNamespace::subjectEquals.
testIsCapitalizedWithWgCapitalLinkOverrides()
Counter part for MWNamespace::testIsCapitalizedWithWgCapitalLinks() now testing the $wgCapitalLinkOve...
static isMovable($index)
Can pages in the given namespace be moved?
static hasGenderDistinction($index)
Does the namespace (potentially) have different aliases for different genders.
$wgNamespacesWithSubpages
Which namespaces should support subpages? See Language.php for a list of namespaces.
static isNonincludable($index)
It is not possible to use pages from this namespace as template?
static getSubjectNamespaces()
List all namespace indices which are considered subject, aka not a talk or special namespace...
Test class for MWNamespace.
testIsContent()
MWNamespace::isContent.
testGetTalk()
Regular getTalk() calls Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in the funct...
testCanTalk()
MWNamespace::canTalk.
testGetContentNamespaces()
MWNamespace::getContentNamespaces.
static getTalkNamespaces()
List all namespace indices which are considered talks, aka not a subject or special namespace...
when a variable name is used in a it is silently declared as a new local masking the global
testGetTalkExceptionsForNsSpecial()
Exceptions with getTalk() NS_SPECIAL does not have talk pages.
testHasGenderDistinction()
MWNamespace::hasGenderDistinction.
testHasSubpages()
MWNamespace::hasSubpages.
static isCapitalized($index)
Is the namespace first-letter capitalized?
testGetAssociated()
Regular getAssociated() calls Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested...
static getCanonicalName($index)
Returns the canonical (English) name for a given index.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
testIsNonincludable()
MWNamespace::isNonincludable.
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
Wikitext formatted, in the key only.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
static subjectEquals($ns1, $ns2)
Returns whether the specified namespaces share the same subject.
testIsCapitalizedHardcodedAssertions()
Some namespaces are always capitalized per code definition in MWNamespace::$alwaysCapitalizedNamespac...
testGetTalkNamespaces()
MWNamespace::getTalkNamespaces.
testIsWatchable()
MWNamespace::isWatchable.
assertSameSubject($ns1, $ns2, $msg= '')
static equals($ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
testGetSubjectNamespaces()
MWNamespace::getSubjectNamespaces.
$wgContentNamespaces
Array of namespaces which can be deemed to contain valid "content", as far as the site statistics are...
static getTalk($index)
Get the talk namespace index for a given namespace.
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
testIsSubject()
Please make sure to change testIsTalk() if you change the assertions below MWNamespace::isSubject.
assertDifferentSubject($ns1, $ns2, $msg= '')
testIsTalk()
Reverse of testIsSubject().
testIsCapitalizedWithWgCapitalLinks()
Follows up for testIsCapitalizedHardcodedAssertions() but alter the global $wgCapitalLink setting to ...
testEquals()
Test MWNamespace::equals Note if we add a namespace registration system with keys like 'MAIN' we shou...
testGetAssociatedExceptionsForNsMedia()
MWException MWNamespace::getAssociated.
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
static getAssociated($index)
Get the associated namespace.
testIsContentAdvanced()
Similar to testIsContent() but alters the $wgContentNamespaces global variable.
testGetSubject()
MWNamespace::getSubject.
testSubjectEquals()
MWNamespace::subjectEquals.
testGetAssociatedExceptionsForNsSpecial()
MWException MWNamespace::getAssociated.
testGetTalkExceptionsForNsMedia()
Exceptions with getTalk() NS_MEDIA does not have talk pages.