From 08334c06c8def7daddac47a7b1ef9b7a15f87d43 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 15 Aug 2011 14:17:45 +0000 Subject: [PATCH] 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. --- tests/phpunit/includes/MWNamespaceTest.php | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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 -- 2.20.1