diff options
author | Alexandre Emsenhuber <ialex.wiki@gmail.com> | 2012-11-05 11:10:42 +0100 |
---|---|---|
committer | Antoine Musso <hashar@free.fr> | 2012-11-17 09:53:34 +0100 |
commit | 07818096dfb37bb960b01cd0e062193b201aeae4 (patch) | |
tree | d17d546358c7a13431c2c2eb07fa687f965f20ec /tests/phpunit/includes | |
parent | 0caeb7724b1739f148b0e9372fbb1c9e3e7391c6 (diff) | |
download | mediawikicore-07818096dfb37bb960b01cd0e062193b201aeae4.tar.gz mediawikicore-07818096dfb37bb960b01cd0e062193b201aeae4.zip |
(bug 35204) set wgLanguageCode in unit tests
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.
This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:
"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"
Follow-up of I2987db68 (2b0edc8).
Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
Diffstat (limited to 'tests/phpunit/includes')
-rw-r--r-- | tests/phpunit/includes/LanguageConverterTest.php | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/RevisionTest.php | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/SampleTest.php | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/TimeAdjustTest.php | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/TitlePermissionTest.php | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/parser/MagicVariableTest.php | 19 | ||||
-rw-r--r-- | tests/phpunit/includes/parser/NewParserTest.php | 5 |
7 files changed, 20 insertions, 9 deletions
diff --git a/tests/phpunit/includes/LanguageConverterTest.php b/tests/phpunit/includes/LanguageConverterTest.php index 9fc6f4d4dad4..eb8912d54c2b 100644 --- a/tests/phpunit/includes/LanguageConverterTest.php +++ b/tests/phpunit/includes/LanguageConverterTest.php @@ -9,6 +9,7 @@ class LanguageConverterTest extends MediaWikiLangTestCase { $this->setMwGlobals( array( 'wgContLang' => Language::factory( 'tg' ), + 'wgLanguageCode' => 'tg', 'wgDefaultLanguageVariant' => false, 'wgMemc' => new EmptyBagOStuff, 'wgRequest' => new FauxRequest( array() ), diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 00e711966075..9cddbe827ef3 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -11,6 +11,7 @@ class RevisionTest extends MediaWikiTestCase { $this->setMwGlobals( array( 'wgContLang' => Language::factory( 'en' ), + 'wgLanguageCode' => 'en', 'wgLegacyEncoding' => false, 'wgCompressRevisions' => false, diff --git a/tests/phpunit/includes/SampleTest.php b/tests/phpunit/includes/SampleTest.php index 2f55de4da330..1324d5046348 100644 --- a/tests/phpunit/includes/SampleTest.php +++ b/tests/phpunit/includes/SampleTest.php @@ -15,6 +15,7 @@ class TestSample extends MediaWikiLangTestCase { // after each test. $this->setMwGlobals( array( 'wgContLang' => Language::factory( 'en' ), + 'wgLanguageCode' => 'en', ) ); } diff --git a/tests/phpunit/includes/TimeAdjustTest.php b/tests/phpunit/includes/TimeAdjustTest.php index db4162fa0739..07ce84bf0295 100644 --- a/tests/phpunit/includes/TimeAdjustTest.php +++ b/tests/phpunit/includes/TimeAdjustTest.php @@ -7,6 +7,7 @@ class TimeAdjustTest extends MediaWikiLangTestCase { $this->setMwGlobals( array( 'wgLocalTZoffset' => null, 'wgContLang' => Language::factory( 'en' ), + 'wgLanguageCode' => 'en', ) ); $this->iniSet( 'precision', 15 ); diff --git a/tests/phpunit/includes/TitlePermissionTest.php b/tests/phpunit/includes/TitlePermissionTest.php index 55c56101a6cf..3a30b12524bd 100644 --- a/tests/phpunit/includes/TitlePermissionTest.php +++ b/tests/phpunit/includes/TitlePermissionTest.php @@ -30,6 +30,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase { $this->setMwGlobals( array( 'wgMemc' => new EmptyBagOStuff, 'wgContLang' => $langObj, + 'wgLanguageCode' => 'en', 'wgLang' => $langObj, 'wgLocaltimezone' => $localZone, 'wgLocalTZoffset' => $localOffset, diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 611a45a04333..5f670fc54e8b 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -33,7 +33,10 @@ class MagicVariableTest extends MediaWikiTestCase { parent::setUp(); $contLang = Language::factory( 'en' ); - $this->setMwGlobals( 'wgContLang', $contLang ); + $this->setMwGlobals( array( + 'wgLanguageCode' => 'en', + 'wgContLang' => $contLang, + ) ); $this->testParser = new Parser(); $this->testParser->Options( ParserOptions::newFromUserAndLang( new User, $contLang ) ); @@ -78,7 +81,7 @@ class MagicVariableTest extends MediaWikiTestCase { function testLocaldaytwoIsZeroPadded( $day ) { $this->assertZeroPadded( 'localday2', $day ); } - + # month /** @dataProvider MediaWikiProvide::Months */ @@ -109,7 +112,7 @@ class MagicVariableTest extends MediaWikiTestCase { function testRevisiondaytwoIsZeroPadded( $day ) { $this->assertZeroPadded( 'revisionday2', $day ); } - + # revision month /** @dataProvider MediaWikiProvide::Months */ @@ -153,26 +156,26 @@ class MagicVariableTest extends MediaWikiTestCase { /** * Main assertion helper for magic variables padding - * @param $magic string Magic variable name + * @param $magic string Magic variable name * @param $value mixed Month or day - * @param $format string sprintf format for $value + * @param $format string sprintf format for $value */ private function assertMagicPadding( $magic, $value, $format ) { # Initialize parser timestamp as year 2010 at 12h34 56s. # month and day are given by the caller ($value). Month < 12! if( $value > 12 ) { $month = $value % 12; } else { $month = $value; } - + $this->setParserTS( sprintf( '2010%02d%02d123456', $month, $value ) ); - # please keep the following commented line of code. It helps debugging. + # please keep the following commented line of code. It helps debugging. //print "\nDEBUG (value $value):" . sprintf( '2010%02d%02d123456', $value, $value ) . "\n"; # format expectation and test it $expected = sprintf( $format, $value ); - $this->assertMagic( $expected, $magic ); + $this->assertMagic( $expected, $magic ); } /** helper to set the parser timestamp and revision timestamp */ diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 17d6ca35b8fc..401962fba89a 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -32,8 +32,11 @@ class NewParserTest extends MediaWikiTestCase { protected $file = false; protected function setUp() { - global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases; + global $wgContLang, $wgLanguageCode; + global $wgNamespaceProtection, $wgNamespaceAliases; global $wgHooks, $IP; + + $wgLanguageCode = 'en'; $wgContLang = Language::factory( 'en' ); //Setup CLI arguments |