From e9fa97f76e156df328fc90b42fd8ff0689495d14 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 11 May 2012 19:52:34 +0200 Subject: [PATCH] Add unit test for MWNamespace::isNonincludable rename MWNamespace::isNonincludableNamespace to MWNamespace::isNonincludable, because "Namespace" is already in the class name Change-Id: Ie982835c7dc84cb10c823996e5360cc1b342f704 --- includes/Namespace.php | 2 +- includes/api/ApiQuerySiteinfo.php | 2 +- includes/parser/Parser.php | 2 +- tests/phpunit/includes/MWNamespaceTest.php | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/Namespace.php b/includes/Namespace.php index bdccca16eb..9ec69482f3 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -361,7 +361,7 @@ class MWNamespace { * @param $index int Index to check * @return bool */ - public static function isNonincludableNamespace( $index ) { + public static function isNonincludable( $index ) { global $wgNonincludableNamespaces; return $wgNonincludableNamespaces && in_array( $index, $wgNonincludableNamespaces ); } diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index fc5d7bb365..e7102e0011 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -216,7 +216,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[$ns]['content'] = ''; } - if ( MWNamespace::isNonincludableNamespace( $ns ) ) { + if ( MWNamespace::isNonincludable( $ns ) ) { $data[$ns]['nonincludable'] = ''; } } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ba7ff6055c..fa98dbf6a4 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3309,7 +3309,7 @@ class Parser { $isHTML = true; $this->disableCache(); } - } elseif ( MWNamespace::isNonincludableNamespace( $title->getNamespace() ) ) { + } elseif ( MWNamespace::isNonincludable( $title->getNamespace() ) ) { $found = false; # access denied wfDebug( __METHOD__.": template inclusion denied for " . $title->getPrefixedDBkey() ); } else { diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php index d4590228cf..da36ffda40 100644 --- a/tests/phpunit/includes/MWNamespaceTest.php +++ b/tests/phpunit/includes/MWNamespaceTest.php @@ -546,6 +546,15 @@ class MWNamespaceTest extends MediaWikiTestCase { } + public function testIsNonincludable() { + global $wgNonincludableNamespaces; + $wgNonincludableNamespaces = array( NS_USER ); + + $this->assertTrue( MWNamespace::isNonincludable( NS_USER ) ); + + $this->assertFalse( MWNamespace::isNonincludable( NS_TEMPLATE ) ); + } + ####### HELPERS ########################################################### function __call( $method, $args ) { // Call the real method if it exists -- 2.20.1