r95422 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95421‎ | r95422 | r95423 >
Date:19:32, 24 August 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Followup r82577

Remove $this->object

Swap assertEquals parameters
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/MWNamespaceTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/MWNamespaceTest.php
@@ -12,16 +12,10 @@
1313 */
1414 class MWNamespaceTest extends MediaWikiTestCase {
1515 /**
16 - * @var MWNamespace
17 - */
18 - protected $object;
19 -
20 - /**
2116 * Sets up the fixture, for example, opens a network connection.
2217 * This method is called before a test is executed.
2318 */
2419 protected function setUp() {
25 - $this->object = new MWNamespace;
2620 }
2721
2822 /**
@@ -87,7 +81,7 @@
8882 * the function testGetTalkExceptions()
8983 */
9084 public function testGetTalk() {
91 - $this->assertEquals( MWNamespace::getTalk( NS_MAIN), NS_TALK );
 85+ $this->assertEquals( NS_TALK, MWNamespace::getTalk( NS_MAIN ) );
9286 }
9387
9488 /**
@@ -101,13 +95,13 @@
10296 }
10397
10498 /**
105 - * Regular getAssociated() calls
 99+ * Regular getAssociated() calls
106100 * Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested in
107101 * the function testGetAssociatedExceptions()
108102 */
109103 public function testGetAssociated() {
110 - $this->assertEquals( MWNamespace::getAssociated( NS_MAIN ), NS_TALK );
111 - $this->assertEquals( MWNamespace::getAssociated( NS_TALK ), NS_MAIN );
 104+ $this->assertEquals( NS_TALK, MWNamespace::getAssociated( NS_MAIN ) );
 105+ $this->assertEquals( NS_MAIN, MWNamespace::getAssociated( NS_TALK ) );
112106
113107 }
114108
@@ -131,11 +125,11 @@
132126 */
133127 public function testGetSubject() {
134128 // Special namespaces are their own subjects
135 - $this->assertEquals( MWNamespace::getSubject( NS_MEDIA ), NS_MEDIA );
136 - $this->assertEquals( MWNamespace::getSubject( NS_SPECIAL ), NS_SPECIAL );
 129+ $this->assertEquals( NS_MEDIA, MWNamespace::getSubject( NS_MEDIA ) );
 130+ $this->assertEquals( NS_SPECIAL, MWNamespace::getSubject( NS_SPECIAL ) );
137131
138 - $this->assertEquals( MWNamespace::getSubject( NS_TALK ), NS_MAIN );
139 - $this->assertEquals( MWNamespace::getSubject( NS_USER_TALK ), NS_USER );
 132+ $this->assertEquals( NS_MAIN, MWNamespace::getSubject( NS_TALK ) );
 133+ $this->assertEquals( NS_USER, MWNamespace::getSubject( NS_USER_TALK ) );
140134 }
141135
142136 /**
@@ -230,7 +224,7 @@
231225 * Similar to testIsContent() but alters the $wgContentNamespaces
232226 * global variable.
233227 */
234 - public function testIsContentWithAdditionsInWgContentNamespaces() {
 228+ public function testIsContentWithAdditionsInWgContentNamespaces() {
235229 // NS_MAIN is a content namespace per DefaultSettings.php
236230 // and per function definition.
237231 $this->assertTrue( MWNamespace::isContent( NS_MAIN ) );
@@ -306,8 +300,8 @@
307301 */
308302 public function testGetContentNamespaces() {
309303 $this->assertEquals(
 304+ array( NS_MAIN ),
310305 MWNamespace::getcontentNamespaces(),
311 - array( NS_MAIN),
312306 '$wgContentNamespaces is an array with only NS_MAIN by default'
313307 );
314308
@@ -315,37 +309,37 @@
316310
317311 # test !is_array( $wgcontentNamespaces )
318312 $wgContentNamespaces = '';
319 - $this->assertEquals( MWNamespace::getcontentNamespaces(), NS_MAIN );
 313+ $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
320314 $wgContentNamespaces = false;
321 - $this->assertEquals( MWNamespace::getcontentNamespaces(), NS_MAIN );
 315+ $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
322316 $wgContentNamespaces = null;
323 - $this->assertEquals( MWNamespace::getcontentNamespaces(), NS_MAIN );
 317+ $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
324318 $wgContentNamespaces = 5;
325 - $this->assertEquals( MWNamespace::getcontentNamespaces(), NS_MAIN );
 319+ $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
326320
327 - # test $wgContentNamespaces === array()
 321+ # test $wgContentNamespaces === array()
328322 $wgContentNamespaces = array();
329 - $this->assertEquals( MWNamespace::getcontentNamespaces(), NS_MAIN );
 323+ $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
330324
331325 # test !in_array( NS_MAIN, $wgContentNamespaces )
332326 $wgContentNamespaces = array( NS_USER, NS_CATEGORY );
333327 $this->assertEquals(
334 - MWNamespace::getcontentNamespaces(),
335328 array( NS_MAIN, NS_USER, NS_CATEGORY ),
 329+ MWNamespace::getcontentNamespaces(),
336330 'NS_MAIN is forced in wgContentNamespaces even if unwanted'
337331 );
338332
339333 # test other cases, return $wgcontentNamespaces as is
340334 $wgContentNamespaces = array( NS_MAIN );
341335 $this->assertEquals(
342 - MWNamespace::getcontentNamespaces(),
343 - array( NS_MAIN )
 336+ array( NS_MAIN ),
 337+ MWNamespace::getcontentNamespaces()
344338 );
345339
346340 $wgContentNamespaces = array( NS_MAIN, NS_USER, NS_CATEGORY );
347341 $this->assertEquals(
348 - MWNamespace::getcontentNamespaces(),
349 - array( NS_MAIN, NS_USER, NS_CATEGORY )
 342+ array( NS_MAIN, NS_USER, NS_CATEGORY ),
 343+ MWNamespace::getcontentNamespaces()
350344 );
351345
352346 }
@@ -456,7 +450,7 @@
457451 $this->assertFalse( MWNamespace::hasGenderDistinction( NS_SPECIAL ) );
458452 $this->assertFalse( MWNamespace::hasGenderDistinction( NS_MAIN ) );
459453 $this->assertFalse( MWNamespace::hasGenderDistinction( NS_TALK ) );
460 -
 454+
461455 }
462456 }
463457

Follow-up revisions

RevisionCommit summaryAuthorDate
r95632MFT to REL1_18...hashar17:57, 28 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82577improve namespace related methods...hashar22:17, 21 February 2011

Comments

#Comment by Hashar (talk | contribs)   19:57, 24 August 2011

Thanks a lot Reedy for dealing with it. I owe you another beer.

Status & tagging log