From: Antoine Musso Date: Mon, 15 Aug 2011 14:17:45 +0000 (+0000) Subject: Fix up NS_MAIN subpage tests X-Git-Tag: 1.31.0-rc.0~28258 X-Git-Url: http://git.cyclocoop.org/data/modifier.php?a=commitdiff_plain;h=08334c06c8def7daddac47a7b1ef9b7a15f87d43;p=lhc%2Fweb%2Fwiklou.git Fix up NS_MAIN subpage tests Per CR on r92234, this correctly test hasSubpages independently from your local configuration. Also test altering the global and having static methods reacting accordingly. --- diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php index 32d83fda46..1e3273f280 100644 --- a/tests/phpunit/includes/MWNamespaceTest.php +++ b/tests/phpunit/includes/MWNamespaceTest.php @@ -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