r87210 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87209‎ | r87210 | r87211 >
Date:19:32, 1 May 2011
Author:platonides
Status:ok
Tags:
Comment:
Fix the old XmlTest.php test bug in the dateMenu() when the wiki is configured for a languange other than English
Other tests were running before and messing with the Language objects.
Modified paths:
  • /trunk/phase3/tests/phpunit/MediaWikiLangTestCase.php (added) (history)
  • /trunk/phase3/tests/phpunit/includes/LanguageConverterTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/MessageTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/SampleTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/XmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/MediaWikiLangTestCase.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Base class that store and restore the Language objects
 6+ */
 7+class MediaWikiLangTestCase extends MediaWikiTestCase {
 8+ private static $oldLang;
 9+ private static $oldContLang;
 10+
 11+ public function setUp() {
 12+ global $wgLanguageCode, $wgLang, $wgContLang;
 13+
 14+ self::$oldLang = $wgLang;
 15+ self::$oldContLang = $wgContLang;
 16+
 17+ if( $wgLanguageCode != $wgContLang->getCode() ) die("nooo!");
 18+
 19+ $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
 20+
 21+ $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
 22+ MessageCache::singleton()->disable();
 23+ }
 24+
 25+ public function tearDown() {
 26+ global $wgContLang, $wgLang, $wgLanguageCode;
 27+ $wgLang = self::$oldLang;
 28+
 29+ $wgContLang = self::$oldContLang;
 30+ $wgLanguageCode = $wgContLang->getCode();
 31+ }
 32+
 33+}
Property changes on: trunk/phase3/tests/phpunit/MediaWikiLangTestCase.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/phase3/tests/phpunit/includes/XmlTest.php
@@ -1,7 +1,22 @@
22 <?php
33
44 class XmlTest extends MediaWikiTestCase {
 5+ private static $oldLang;
56
 7+ public function setUp() {
 8+ global $wgLang, $wgLanguageCode;
 9+
 10+ self::$oldLang = $wgLang;
 11+ $wgLanguageCode = 'en';
 12+ $wgLang = Language::factory( $wgLanguageCode );
 13+ }
 14+
 15+ public function tearDown() {
 16+ global $wgContLang, $wgLanguageCode;
 17+ $wgLang = self::$oldLang;
 18+ $wgLanguageCode = $wgLang->getCode();
 19+ }
 20+
621 public function testExpandAttributes() {
722 $this->assertNull( Xml::expandAttributes(null),
823 'Converting a null list of attributes'
Index: trunk/phase3/tests/phpunit/includes/LanguageConverterTest.php
@@ -1,10 +1,12 @@
22 <?php
33
4 -class LanguageConverterTest extends MediaWikiTestCase {
 4+
 5+class LanguageConverterTest extends MediaWikiLangTestCase {
56 protected $lang = null;
67 protected $lc = null;
78
89 function setUp() {
 10+ parent::setUp();
911 global $wgMemc, $wgRequest, $wgUser, $wgContLang;
1012
1113 $wgUser = new User;
Index: trunk/phase3/tests/phpunit/includes/SampleTest.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -class TestSample extends MediaWikiTestCase {
 4+class TestSample extends MediaWikiLangTestCase {
55
66 /**
77 * Anything that needs to happen before your tests should go here.
Index: trunk/phase3/tests/phpunit/includes/MessageTest.php
@@ -1,16 +1,7 @@
22 <?php
33
4 -class MessageTest extends MediaWikiTestCase {
 4+class MessageTest extends MediaWikiLangTestCase {
55
6 - function setUp() {
7 - global $wgLanguageCode, $wgLang, $wgContLang;
8 -
9 - $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
10 - //Note that a Stub Object is not enough for this test
11 - $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
12 - MessageCache::singleton()->disable();
13 - }
14 -
156 function testExists() {
167 $this->assertTrue( wfMessage( 'mainpage' )->exists() );
178 $this->assertTrue( wfMessage( 'mainpage' )->params( array() )->exists() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r87229Follow up r87210platonides23:02, 1 May 2011
r87364Follow up r87210platonides22:37, 3 May 2011
r87392Follow-up r87210: Add MediaWikiLangTestCase to the autoloader and make the cl...pcopp11:46, 4 May 2011
r90090Thou shall call parent::tearDown(), MediaWikiLangTestCase child....platonides21:21, 14 June 2011

Status & tagging log