Merge "Begin 1.27 development cycle"
[lhc/web/wiklou.git] / tests / phpunit / includes / MWNamespaceTest.php
index 10e9db6..4fc54e8 100644 (file)
@@ -8,6 +8,8 @@
 /**
  * Test class for MWNamespace.
  * Generated by PHPUnit on 2011-02-20 at 21:01:55.
+ * @todo covers tags
+ * @todo FIXME: this test file is a mess
  *
  */
 class MWNamespaceTest extends MediaWikiTestCase {
@@ -27,18 +29,20 @@ class MWNamespaceTest extends MediaWikiTestCase {
                ) );
        }
 
-#### START OF TESTS #########################################################
+# ### START OF TESTS #########################################################
 
        /**
         * @todo Write more texts, handle $wgAllowImageMoving setting
+        * @covers MWNamespace::isMovable
         */
        public function testIsMovable() {
-               $this->assertFalse( MWNamespace::isMovable( NS_CATEGORY ) );
+               $this->assertFalse( MWNamespace::isMovable( NS_SPECIAL ) );
                # @todo FIXME: Write more tests!!
        }
 
        /**
         * Please make sure to change testIsTalk() if you change the assertions below
+        * @covers MWNamespace::isSubject
         */
        public function testIsSubject() {
                // Special namespaces
@@ -59,6 +63,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        /**
         * Reverse of testIsSubject().
         * Please update testIsSubject() if you change assertions below
+        * @covers MWNamespace::isTalk
         */
        public function testIsTalk() {
                // Special namespaces
@@ -77,6 +82,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers MWNamespace::getSubject
         */
        public function testGetSubject() {
                // Special namespaces are their own subjects
@@ -91,6 +97,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Regular getTalk() calls
         * Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in
         * the function testGetTalkExceptions()
+        * @covers MWNamespace::getTalk
         */
        public function testGetTalk() {
                $this->assertEquals( NS_TALK, MWNamespace::getTalk( NS_MAIN ) );
@@ -103,6 +110,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Exceptions with getTalk()
         * NS_MEDIA does not have talk pages. MediaWiki raise an exception for them.
         * @expectedException MWException
+        * @covers MWNamespace::getTalk
         */
        public function testGetTalkExceptionsForNsMedia() {
                $this->assertNull( MWNamespace::getTalk( NS_MEDIA ) );
@@ -112,6 +120,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Exceptions with getTalk()
         * NS_SPECIAL does not have talk pages. MediaWiki raise an exception for them.
         * @expectedException MWException
+        * @covers MWNamespace::getTalk
         */
        public function testGetTalkExceptionsForNsSpecial() {
                $this->assertNull( MWNamespace::getTalk( NS_SPECIAL ) );
@@ -121,17 +130,19 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Regular getAssociated() calls
         * Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested in
         * the function testGetAssociatedExceptions()
+        * @covers MWNamespace::getAssociated
         */
        public function testGetAssociated() {
                $this->assertEquals( NS_TALK, MWNamespace::getAssociated( NS_MAIN ) );
                $this->assertEquals( NS_MAIN, MWNamespace::getAssociated( NS_TALK ) );
        }
 
-       ### Exceptions with getAssociated()
-       ### NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
-       ### an exception for them.
+       # ## Exceptions with getAssociated()
+       # ## NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
+       # ## an exception for them.
        /**
         * @expectedException MWException
+        * @covers MWNamespace::getAssociated
         */
        public function testGetAssociatedExceptionsForNsMedia() {
                $this->assertNull( MWNamespace::getAssociated( NS_MEDIA ) );
@@ -139,6 +150,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
 
        /**
         * @expectedException MWException
+        * @covers MWNamespace::getAssociated
         */
        public function testGetAssociatedExceptionsForNsSpecial() {
                $this->assertNull( MWNamespace::getAssociated( NS_SPECIAL ) );
@@ -161,6 +173,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * Note if we add a namespace registration system with keys like 'MAIN'
         * we should add tests here for equivilance on things like 'MAIN' == 0
         * and 'MAIN' == NS_MAIN.
+        * @covers MWNamespace::equals
         */
        public function testEquals() {
                $this->assertTrue( MWNamespace::equals( NS_MAIN, NS_MAIN ) );
@@ -175,7 +188,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
-        * Test MWNamespace::subjectEquals
+        * @covers MWNamespace::subjectEquals
         */
        public function testSubjectEquals() {
                $this->assertSameSubject( NS_MAIN, NS_MAIN );
@@ -191,6 +204,9 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertDifferentSubject( NS_SPECIAL, NS_MAIN );
        }
 
+       /**
+        * @covers MWNamespace::subjectEquals
+        */
        public function testSpecialAndMediaAreDifferentSubjects() {
                $this->assertDifferentSubject(
                        NS_MEDIA, NS_SPECIAL,
@@ -249,6 +265,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        */
 
        /**
+        * @covers MWNamespace::canTalk
         */
        public function testCanTalk() {
                $this->assertCanNotTalk( NS_MEDIA );
@@ -265,6 +282,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers MWNamespace::isContent
         */
        public function testIsContent() {
                // NS_MAIN is a content namespace per DefaultSettings.php
@@ -285,6 +303,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        /**
         * Similar to testIsContent() but alters the $wgContentNamespaces
         * global variable.
+        * @covers MWNamespace::isContent
         */
        public function testIsContentAdvanced() {
                global $wgContentNamespaces;
@@ -301,6 +320,9 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsContent( NS_MAIN );
        }
 
+       /**
+        * @covers MWNamespace::isWatchable
+        */
        public function testIsWatchable() {
                // Specials namespaces are not watchable
                $this->assertIsNotWatchable( NS_MEDIA );
@@ -315,6 +337,9 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsWatchable( 101 );
        }
 
+       /**
+        * @covers MWNamespace::hasSubpages
+        */
        public function testHasSubpages() {
                global $wgNamespacesWithSubpages;
 
@@ -338,6 +363,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers MWNamespace::getContentNamespaces
         */
        public function testGetContentNamespaces() {
                global $wgContentNamespaces;
@@ -388,6 +414,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers MWNamespace::getSubjectNamespaces
         */
        public function testGetSubjectNamespaces() {
                $subjectsNS = MWNamespace::getSubjectNamespaces();
@@ -403,6 +430,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers MWNamespace::getTalkNamespaces
         */
        public function testGetTalkNamespaces() {
                $talkNS = MWNamespace::getTalkNamespaces();
@@ -420,6 +448,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
        /**
         * Some namespaces are always capitalized per code definition
         * in MWNamespace::$alwaysCapitalizedNamespaces
+        * @covers MWNamespace::isCapitalized
         */
        public function testIsCapitalizedHardcodedAssertions() {
                // NS_MEDIA and NS_FILE are treated the same
@@ -451,6 +480,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         *
         * Global setting correctness is tested against the NS_PROJECT and
         * NS_PROJECT_TALK namespaces since they are not hardcoded nor specials
+        * @covers MWNamespace::isCapitalized
         */
        public function testIsCapitalizedWithWgCapitalLinks() {
                global $wgCapitalLinks;
@@ -475,6 +505,7 @@ class MWNamespaceTest extends MediaWikiTestCase {
         * testing the $wgCapitalLinkOverrides global.
         *
         * @todo split groups of assertions in autonomous testing functions
+        * @covers MWNamespace::isCapitalized
         */
        public function testIsCapitalizedWithWgCapitalLinkOverrides() {
                global $wgCapitalLinkOverrides;
@@ -507,6 +538,9 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsCapitalized( NS_PROJECT );
        }
 
+       /**
+        * @covers MWNamespace::hasGenderDistinction
+        */
        public function testHasGenderDistinction() {
                // Namespaces with gender distinctions
                $this->assertTrue( MWNamespace::hasGenderDistinction( NS_USER ) );
@@ -519,6 +553,9 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertFalse( MWNamespace::hasGenderDistinction( NS_TALK ) );
        }
 
+       /**
+        * @covers MWNamespace::isNonincludable
+        */
        public function testIsNonincludable() {
                global $wgNonincludableNamespaces;
 
@@ -528,14 +565,18 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertFalse( MWNamespace::isNonincludable( NS_TEMPLATE ) );
        }
 
-       ####### HELPERS ###########################################################
+       # ###### HELPERS ###########################################################
        function __call( $method, $args ) {
                // Call the real method if it exists
                if ( method_exists( $this, $method ) ) {
                        return $this->$method( $args );
                }
 
-               if ( preg_match( '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/', $method, $m ) ) {
+               if ( preg_match(
+                       '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
+                       $method,
+                       $m
+               ) ) {
                        # Interprets arguments:
                        $ns = $args[0];
                        $msg = isset( $args[1] ) ? $args[1] : " dummy message";