r105894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105893‎ | r105894 | r105895 >
Date:15:39, 12 December 2011
Author:hashar
Status:ok
Tags:
Comment:
use an helper to test NS subjects
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/MWNamespaceTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/MWNamespaceTest.php
@@ -182,25 +182,28 @@
183183 * Test MWNamespace::subjectEquals
184184 */
185185 public function testSubjectEquals() {
186 - $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, NS_MAIN ) );
187 - $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, 0 ) ); // In case we make NS_MAIN 'MAIN'
188 - $this->assertTrue( MWNamespace::subjectEquals( NS_USER, NS_USER ) );
189 - $this->assertTrue( MWNamespace::subjectEquals( NS_USER, 2 ) );
190 - $this->assertTrue( MWNamespace::subjectEquals( NS_USER_TALK, NS_USER_TALK ) );
191 - $this->assertTrue( MWNamespace::subjectEquals( NS_SPECIAL, NS_SPECIAL ) );
192 - $this->assertTrue( MWNamespace::subjectEquals( NS_MAIN, NS_TALK ) );
193 - $this->assertTrue( MWNamespace::subjectEquals( NS_USER, NS_USER_TALK ) );
194 - $this->assertFalse( MWNamespace::subjectEquals( NS_PROJECT, NS_TEMPLATE ) );
195 - $this->assertFalse( MWNamespace::subjectEquals( NS_SPECIAL, NS_MAIN ) );
 186+ $this->assertSameSubject( NS_MAIN, NS_MAIN );
 187+ $this->assertSameSubject( NS_MAIN, 0 ); // In case we make NS_MAIN 'MAIN'
 188+ $this->assertSameSubject( NS_USER, NS_USER );
 189+ $this->assertSameSubject( NS_USER, 2 );
 190+ $this->assertSameSubject( NS_USER_TALK, NS_USER_TALK );
 191+ $this->assertSameSubject( NS_SPECIAL, NS_SPECIAL );
 192+ $this->assertSameSubject( NS_MAIN, NS_TALK );
 193+ $this->assertSameSubject( NS_USER, NS_USER_TALK );
 194+
 195+ $this->assertDifferentSubject( NS_PROJECT, NS_TEMPLATE );
 196+ $this->assertDifferentSubject( NS_SPECIAL, NS_MAIN );
196197 }
197198
198199 public function testSpecialAndMediaAreDifferentSubjects() {
199 - $this->assertFalse( MWNamespace::subjectEquals(
200 - NS_MEDIA, NS_SPECIAL
201 - ), "NS_MEDIA and NS_SPECIAL are different subhects" );
202 - $this->assertFalse( MWNamespace::subjectEquals(
203 - NS_SPECIAL, NS_MEDIA
204 - ), "NS_SPECIAL and NS_MEDIA are different subhects" );
 200+ $this->assertDifferentSubject(
 201+ NS_MEDIA, NS_SPECIAL,
 202+ "NS_MEDIA and NS_SPECIAL are different subhects"
 203+ );
 204+ $this->assertDifferentSubject(
 205+ NS_SPECIAL, NS_MEDIA,
 206+ "NS_SPECIAL and NS_MEDIA are different subhects"
 207+ );
205208
206209 }
207210
@@ -580,5 +583,11 @@
581584 throw new Exception( __METHOD__ . " could not find a method named $method\n" );
582585 }
583586
 587+ function assertSameSubject( $ns1, $ns2, $msg = '' ) {
 588+ $this->assertTrue( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
 589+ }
 590+ function assertDifferentSubject( $ns1, $ns2, $msg = '' ) {
 591+ $this->assertFalse( MWNamespace::subjectEquals( $ns1, $ns2, $msg ) );
 592+ }
584593 }
585594

Status & tagging log