Don't rely on magic __call in MWNamespaceTest
[lhc/web/wiklou.git] / tests / phpunit / includes / MWNamespaceTest.php
index f705537..15e2def 100644 (file)
@@ -31,6 +31,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertFalse( MWNamespace::isMovable( NS_SPECIAL ) );
        }
 
+       private function assertIsSubject( $ns ) {
+               $this->assertTrue( MWNamespace::isSubject( $ns ) );
+       }
+
+       private function assertIsNotSubject( $ns ) {
+               $this->assertFalse( MWNamespace::isSubject( $ns ) );
+       }
+
        /**
         * Please make sure to change testIsTalk() if you change the assertions below
         * @covers MWNamespace::isSubject
@@ -51,6 +59,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsNotSubject( 101 ); # user defined
        }
 
+       private function assertIsTalk( $ns ) {
+               $this->assertTrue( MWNamespace::isTalk( $ns ) );
+       }
+
+       private function assertIsNotTalk( $ns ) {
+               $this->assertFalse( MWNamespace::isTalk( $ns ) );
+       }
+
        /**
         * Reverse of testIsSubject().
         * Please update testIsSubject() if you change assertions below
@@ -236,6 +252,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertSame( $actual, $expected, "NS $index" );
        }
 
+       private function assertIsContent( $ns ) {
+               $this->assertTrue( MWNamespace::isContent( $ns ) );
+       }
+
+       private function assertIsNotContent( $ns ) {
+               $this->assertFalse( MWNamespace::isContent( $ns ) );
+       }
+
        /**
         * @covers MWNamespace::isContent
         */
@@ -275,6 +299,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsContent( NS_MAIN );
        }
 
+       private function assertIsWatchable( $ns ) {
+               $this->assertTrue( MWNamespace::isWatchable( $ns ) );
+       }
+
+       private function assertIsNotWatchable( $ns ) {
+               $this->assertFalse( MWNamespace::isWatchable( $ns ) );
+       }
+
        /**
         * @covers MWNamespace::isWatchable
         */
@@ -292,6 +324,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertIsWatchable( 101 );
        }
 
+       private function assertHasSubpages( $ns ) {
+               $this->assertTrue( MWNamespace::hasSubpages( $ns ) );
+       }
+
+       private function assertHasNotSubpages( $ns ) {
+               $this->assertFalse( MWNamespace::hasSubpages( $ns ) );
+       }
+
        /**
         * @covers MWNamespace::hasSubpages
         */
@@ -400,6 +440,14 @@ class MWNamespaceTest extends MediaWikiTestCase {
                        "Subject namespaces should not have NS_SPECIAL" );
        }
 
+       private function assertIsCapitalized( $ns ) {
+               $this->assertTrue( MWNamespace::isCapitalized( $ns ) );
+       }
+
+       private function assertIsNotCapitalized( $ns ) {
+               $this->assertFalse( MWNamespace::isCapitalized( $ns ) );
+       }
+
        /**
         * Some namespaces are always capitalized per code definition
         * in MWNamespace::$alwaysCapitalizedNamespaces
@@ -520,48 +568,11 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $this->assertFalse( MWNamespace::isNonincludable( NS_TEMPLATE ) );
        }
 
-       # ###### 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
-               ) ) {
-                       # Interprets arguments:
-                       $ns = $args[0];
-                       $msg = isset( $args[1] ) ? $args[1] : " dummy message";
-
-                       # Forge the namespace constant name:
-                       if ( $ns === 0 ) {
-                               $ns_name = "NS_MAIN";
-                       } else {
-                               $ns_name = "NS_" . strtoupper( MWNamespace::getCanonicalName( $ns ) );
-                       }
-                       # ... and the MWNamespace method name
-                       $nsMethod = strtolower( $m[1] ) . $m[3];
-
-                       $expect = ( $m[2] === '' );
-                       $expect_name = $expect ? 'TRUE' : 'FALSE';
-
-                       return $this->assertEquals( $expect,
-                               MWNamespace::$nsMethod( $ns, $msg ),
-                               "MWNamespace::$nsMethod( $ns_name ) should returns $expect_name"
-                       );
-               }
-
-               throw new Exception( __METHOD__ . " could not find a method named $method\n" );
-       }
-
-       function assertSameSubject( $ns1, $ns2, $msg = '' ) {
-               $this->assertTrue( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
+       private function assertSameSubject( $ns1, $ns2, $msg = '' ) {
+               $this->assertTrue( MWNamespace::subjectEquals( $ns1, $ns2 ), $msg );
        }
 
-       function assertDifferentSubject( $ns1, $ns2, $msg = '' ) {
-               $this->assertFalse( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
+       private function assertDifferentSubject( $ns1, $ns2, $msg = '' ) {
+               $this->assertFalse( MWNamespace::subjectEquals( $ns1, $ns2 ), $msg );
        }
 }