Fix up NS_MAIN subpage tests
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 15 Aug 2011 14:17:45 +0000 (14:17 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 15 Aug 2011 14:17:45 +0000 (14:17 +0000)
Per CR on r92234, this correctly test hasSubpages independently from your
local configuration.  Also test altering the global and having static
methods reacting accordingly.

tests/phpunit/includes/MWNamespaceTest.php

index 32d83fd..1e3273f 100644 (file)
@@ -276,13 +276,24 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertFalse( MWNamespace::hasSubpages( NS_SPECIAL ) );
 
                // namespaces without subpages
+               # save up global
                global $wgNamespacesWithSubpages;
-               if(    array_key_exists( NS_MAIN, $wgNamespacesWithSubpages )
-                       && $wgNamespacesWithSubpages[NS_MAIN] === true
-               ) {
-                       $this->markTestSkipped( "Main namespace has subpages enabled" );
-               } else {
-                       $this->assertFalse( MWNamespace::hasSubpages( NS_MAIN ) );
+               $saved = null;
+               if( array_key_exists( NS_MAIN, $wgNamespacesWithSubpages ) ) {
+                       $saved = $wgNamespacesWithSubpages[NS_MAIN];
+                       unset( $wgNamespacesWithSubpages[NS_MAIN] );
+               }
+
+               $this->assertFalse( MWNamespace::hasSubpages( NS_MAIN ) );
+
+               $wgNamespacesWithSubpages[NS_MAIN] = true;
+               $this->assertTrue( MWNamespace::hasSubpages( NS_MAIN ) );
+               $wgNamespacesWithSubpages[NS_MAIN] = false;
+               $this->assertFalse( MWNamespace::hasSubpages( NS_MAIN ) );
+
+               # restore global
+               if( $saved !== null ) {
+                       $wgNamespacesWithSubpages[NS_MAIN] = $saved;
                }
 
                // Some namespaces with subpages