From: Antoine Musso Date: Mon, 12 Dec 2011 15:39:01 +0000 (+0000) Subject: use an helper to test NS subjects X-Git-Tag: 1.31.0-rc.0~26042 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=08b90ed58b031b807dfaaf00a553469204d20027;p=lhc%2Fweb%2Fwiklou.git use an helper to test NS subjects --- diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php index 11e9245e02..1b641145b3 100644 --- a/tests/phpunit/includes/MWNamespaceTest.php +++ b/tests/phpunit/includes/MWNamespaceTest.php @@ -182,25 +182,28 @@ 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->assertFalse( MWNamespace::subjectEquals( NS_SPECIAL, NS_MAIN ) ); + $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->assertFalse( MWNamespace::subjectEquals( - NS_MEDIA, NS_SPECIAL - ), "NS_MEDIA and NS_SPECIAL are different subhects" ); - $this->assertFalse( MWNamespace::subjectEquals( - NS_SPECIAL, NS_MEDIA - ), "NS_SPECIAL and NS_MEDIA are different subhects" ); + $this->assertDifferentSubject( + NS_MEDIA, NS_SPECIAL, + "NS_MEDIA and NS_SPECIAL are different subhects" + ); + $this->assertDifferentSubject( + NS_SPECIAL, NS_MEDIA, + "NS_SPECIAL and NS_MEDIA are different subhects" + ); } @@ -580,5 +583,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 ) ); + } }