r109994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109993‎ | r109994 | r109995 >
Date:03:45, 25 January 2012
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
Fix broken unit test
* r109993 broke the test by overwriting namespaces it tried to preserve
* tearDown should always have the opposite order of the overrides in setUp
* Adding wgLanguageCode while at it, no reason not to, just in case.

-- Follows-up r109993
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/HtmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/HtmlTest.php
@@ -4,6 +4,7 @@
55 class HtmlTest extends MediaWikiTestCase {
66 private static $oldLang;
77 private static $oldContLang;
 8+ private static $oldLanguageCode;
89 private static $oldNamespaces;
910
1011 public function setUp() {
@@ -11,6 +12,8 @@
1213
1314 self::$oldLang = $wgLang;
1415 self::$oldContLang = $wgContLang;
 16+ self::$oldNamespaces = $wgContLang->namespaceNames;
 17+ self::$oldLanguageCode = $wgLanguageCode;
1518
1619 $wgLanguageCode = 'en';
1720 $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
@@ -18,7 +21,6 @@
1922 // Hardcode namespaces during test runs,
2023 // so that html output based on existing namespaces
2124 // can be properly evaluated.
22 - self::$oldNamespaces = $wgContLang->namespaceNames;
2325 $wgContLang->namespaceNames = array(
2426 -2 => 'Media',
2527 -1 => 'Special',
@@ -41,10 +43,11 @@
4244
4345 public function tearDown() {
4446 global $wgLang, $wgContLang, $wgLanguageCode;
 47+
 48+ $wgContLang->namespaceNames = self::$oldNamespaces;
4549 $wgLang = self::$oldLang;
4650 $wgContLang = self::$oldContLang;
47 - $wgLanguageCode = $wgContLang->getCode();
48 - $wgContLang->namespaceNames = self::$oldNamespaces;
 51+ $wgLanguageCode = self::$oldLanguageCode;
4952 }
5053
5154 public function testExpandAttributesSkipsNullAndFalse() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r110118Fixup r109698, add setter for $namespaceNames and use proper accessors in the...demon13:00, 27 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109993[Html] Unit test + bugfix Html::namespaceSelector...krinkle03:25, 25 January 2012

Comments

#Comment by Krinkle (talk | contribs)   03:53, 25 January 2012

In practice restoring namespaceNames in tearDown is pointless as it's parent object is overwritten two lines further, just keeping is simple/consistent/ future proof

Status & tagging log