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"
269 $this->assertCanNotTalk(
NS_MEDIA );
272 $this->assertCanTalk(
NS_MAIN );
273 $this->assertCanTalk(
NS_TALK );
274 $this->assertCanTalk(
NS_USER );
278 $this->assertCanTalk( 100 );
279 $this->assertCanTalk( 101 );
289 $this->assertIsContent(
NS_MAIN );
293 $this->assertIsNotContent(
NS_MEDIA );
295 $this->assertIsNotContent(
NS_TALK );
296 $this->assertIsNotContent(
NS_USER );
298 $this->assertIsNotContent( 100 );
307 global $wgContentNamespaces;
310 $this->assertIsNotContent( 252 );
313 $wgContentNamespaces[] = 252;
315 $this->assertIsContent( 252 );
318 $this->assertIsContent(
NS_MAIN );
326 $this->assertIsNotWatchable(
NS_MEDIA );
330 $this->assertIsWatchable(
NS_MAIN );
331 $this->assertIsWatchable(
NS_TALK );
334 $this->assertIsWatchable( 100 );
335 $this->assertIsWatchable( 101 );
342 global $wgNamespacesWithSubpages;
345 $this->assertHasNotSubpages(
NS_MEDIA );
349 $this->assertHasNotSubpages(
NS_MAIN );
351 $wgNamespacesWithSubpages[
NS_MAIN] =
true;
352 $this->assertHasSubpages(
NS_MAIN );
354 $wgNamespacesWithSubpages[
NS_MAIN] =
false;
355 $this->assertHasNotSubpages(
NS_MAIN );
358 $this->assertHasSubpages(
NS_TALK );
359 $this->assertHasSubpages(
NS_USER );
367 global $wgContentNamespaces;
372 '$wgContentNamespaces is an array with only NS_MAIN by default'
375 # test !is_array( $wgcontentNamespaces )
376 $wgContentNamespaces =
'';
379 $wgContentNamespaces =
false;
382 $wgContentNamespaces =
null;
385 $wgContentNamespaces = 5;
388 # test $wgContentNamespaces === []
389 $wgContentNamespaces = [];
392 # test !in_array( NS_MAIN, $wgContentNamespaces )
397 'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
400 # test other cases, return $wgcontentNamespaces as is
401 $wgContentNamespaces = [
NS_MAIN ];
419 $this->assertContains(
NS_MAIN, $subjectsNS,
420 "Talk namespaces should have NS_MAIN" );
421 $this->assertNotContains(
NS_TALK, $subjectsNS,
422 "Talk namespaces should have NS_TALK" );
424 $this->assertNotContains(
NS_MEDIA, $subjectsNS,
425 "Talk namespaces should not have NS_MEDIA" );
426 $this->assertNotContains(
NS_SPECIAL, $subjectsNS,
427 "Talk namespaces should not have NS_SPECIAL" );
435 $this->assertContains(
NS_TALK, $talkNS,
436 "Subject namespaces should have NS_TALK" );
437 $this->assertNotContains(
NS_MAIN, $talkNS,
438 "Subject namespaces should not have NS_MAIN" );
440 $this->assertNotContains(
NS_MEDIA, $talkNS,
441 "Subject namespaces should not have NS_MEDIA" );
442 $this->assertNotContains(
NS_SPECIAL, $talkNS,
443 "Subject namespaces should not have NS_SPECIAL" );
456 'NS_MEDIA and NS_FILE have same capitalization rendering'
460 $this->assertIsCapitalized(
NS_MEDIA );
461 $this->assertIsCapitalized(
NS_FILE );
466 $this->assertIsCapitalized(
NS_USER );
489 $wgCapitalLinks =
false;
493 $this->assertIsCapitalized(
NS_USER );
509 global $wgCapitalLinkOverrides;
517 $this->assertIsCapitalized(
NS_USER );
522 $wgCapitalLinkOverrides[
NS_USER] =
false;
526 $this->assertIsCapitalized(
NS_USER );
558 global $wgNonincludableNamespaces;
560 $wgNonincludableNamespaces = [
NS_USER ];
566 # ###### HELPERS ###########################################################
569 if ( method_exists( $this, $method ) ) {
570 return $this->$method(
$args );
574 '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
578 # Interprets arguments:
580 $msg = isset(
$args[1] ) ?
$args[1] :
" dummy message";
582 # Forge the namespace constant name:
584 $ns_name =
"NS_MAIN";
588 # ... and the MWNamespace method name
589 $nsMethod = strtolower( $m[1] ) . $m[3];
591 $expect = ( $m[2] ===
'' );
592 $expect_name = $expect ?
'TRUE' :
'FALSE';
594 return $this->assertEquals( $expect,
595 MWNamespace::$nsMethod( $ns, $msg ),
596 "MWNamespace::$nsMethod( $ns_name ) should returns $expect_name"
600 throw new Exception( __METHOD__ .
" could not find a method named $method\n" );