Merge "add Interwiki::selectFields"
[lhc/web/wiklou.git] / tests / phpunit / includes / MWNamespaceTest.php
index aaca2fb..da36ffd 100644 (file)
@@ -53,10 +53,6 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsNotSubject( NS_TALK      );
                $this->assertIsNotSubject( NS_USER_TALK );
                $this->assertIsNotSubject( 101          ); # user defined
-
-               // Back compat
-               $this->assertTrue( MWNamespace::isMain( NS_MAIN ) == MWNamespace::isSubject( NS_MAIN ) );
-               $this->assertTrue( MWNamespace::isMain( NS_USER_TALK ) == MWNamespace::isSubject( NS_USER_TALK ) );
        }
 
        /**
@@ -182,15 +178,29 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Test MWNamespace::subjectEquals
         */
        public function testSubjectEquals() {
-               $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, NS_MAIN ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, 0 ) ); // In case we make NS_MAIN 'MAIN'
-               $this->assertTrue( MWNamespace::subjectEquals( NS_USER, NS_USER ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_USER, 2 ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_USER_TALK, NS_USER_TALK ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_SPECIAL, NS_SPECIAL ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, NS_TALK ) );
-               $this->assertTrue( MWNamespace::subjectEquals( NS_USER, NS_USER_TALK ) );
-               $this->assertFalse( MWNamespace::subjectEquals( NS_PROJECT, NS_TEMPLATE ) );
+               $this->assertSameSubject( NS_MAIN, NS_MAIN );
+               $this->assertSameSubject( NS_MAIN, 0 ); // In case we make NS_MAIN 'MAIN'
+               $this->assertSameSubject( NS_USER, NS_USER );
+               $this->assertSameSubject( NS_USER, 2 );
+               $this->assertSameSubject( NS_USER_TALK, NS_USER_TALK );
+               $this->assertSameSubject( NS_SPECIAL, NS_SPECIAL );
+               $this->assertSameSubject( NS_MAIN, NS_TALK );
+               $this->assertSameSubject( NS_USER, NS_USER_TALK );
+
+               $this->assertDifferentSubject( NS_PROJECT, NS_TEMPLATE );
+               $this->assertDifferentSubject( NS_SPECIAL, NS_MAIN     );
+       }
+
+       public function testSpecialAndMediaAreDifferentSubjects() {
+               $this->assertDifferentSubject(
+                       NS_MEDIA, NS_SPECIAL,
+                       "NS_MEDIA and NS_SPECIAL are different subject namespaces"
+               );
+               $this->assertDifferentSubject(
+                       NS_SPECIAL, NS_MEDIA,
+                       "NS_SPECIAL and NS_MEDIA are different subject namespaces"
+               );
+
        }
 
        /**
@@ -408,7 +418,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertEquals(
                        array( NS_MAIN, NS_USER, NS_CATEGORY ),
                        MWNamespace::getcontentNamespaces(),
-                       'NS_MAIN is forced in wgContentNamespaces even if unwanted'
+                       'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
                );
 
                # test other cases, return $wgcontentNamespaces as is
@@ -536,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
@@ -569,5 +588,11 @@ class MWNamespaceTest extends MediaWikiTestCase {
                throw new Exception( __METHOD__ . " could not find a method named $method\n" );
        }
 
+       function assertSameSubject( $ns1, $ns2, $msg = '' ) {
+               $this->assertTrue( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
+       }
+       function assertDifferentSubject( $ns1, $ns2, $msg = '' ) {
+               $this->assertFalse( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
+       }
 }