aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mehta <legoktm@member.fsf.org>2018-04-06 14:17:22 -0700
committerKunal Mehta <legoktm@member.fsf.org>2018-04-06 14:17:42 -0700
commit9de5c6cd22f39acefedf2a9a74fac3b64b83c0c9 (patch)
treedb5cfc67aefd0de1a455aa15aba1dd07a37acd76
parentdc06d553be36318b88caf7837a39c41b97364dea (diff)
downloadmediawikicore-9de5c6cd22f39acefedf2a9a74fac3b64b83c0c9.tar.gz
mediawikicore-9de5c6cd22f39acefedf2a9a74fac3b64b83c0c9.zip
Don't rely on magic __call in MWNamespaceTest
Change-Id: I32a7e7a55bc733f19d7c5ed1fbc6cfde748d4812
-rw-r--r--tests/phpunit/includes/MWNamespaceTest.php93
1 files changed, 52 insertions, 41 deletions
diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php
index f705537d7580..15e2defcb5f8 100644
--- a/tests/phpunit/includes/MWNamespaceTest.php
+++ b/tests/phpunit/includes/MWNamespaceTest.php
@@ -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 );
}
}