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
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'tg' ),
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'tg' ),
+ 'wgLanguageCode' => 'tg',
'wgDefaultLanguageVariant' => false,
'wgMemc' => new EmptyBagOStuff,
'wgRequest' => new FauxRequest( array() ),
'wgDefaultLanguageVariant' => false,
'wgMemc' => new EmptyBagOStuff,
'wgRequest' => new FauxRequest( array() ),
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'en' ),
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'en' ),
+ 'wgLanguageCode' => 'en',
'wgLegacyEncoding' => false,
'wgCompressRevisions' => false,
'wgLegacyEncoding' => false,
'wgCompressRevisions' => false,
// after each test.
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'en' ),
// after each test.
$this->setMwGlobals( array(
'wgContLang' => Language::factory( 'en' ),
+ 'wgLanguageCode' => 'en',
$this->setMwGlobals( array(
'wgLocalTZoffset' => null,
'wgContLang' => Language::factory( 'en' ),
$this->setMwGlobals( array(
'wgLocalTZoffset' => null,
'wgContLang' => Language::factory( 'en' ),
+ 'wgLanguageCode' => 'en',
) );
$this->iniSet( 'precision', 15 );
) );
$this->iniSet( 'precision', 15 );
$this->setMwGlobals( array(
'wgMemc' => new EmptyBagOStuff,
'wgContLang' => $langObj,
$this->setMwGlobals( array(
'wgMemc' => new EmptyBagOStuff,
'wgContLang' => $langObj,
+ 'wgLanguageCode' => 'en',
'wgLang' => $langObj,
'wgLocaltimezone' => $localZone,
'wgLocalTZoffset' => $localOffset,
'wgLang' => $langObj,
'wgLocaltimezone' => $localZone,
'wgLocalTZoffset' => $localOffset,
parent::setUp();
$contLang = Language::factory( 'en' );
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 ) );
$this->testParser = new Parser();
$this->testParser->Options( ParserOptions::newFromUserAndLang( new User, $contLang ) );
function testLocaldaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'localday2', $day );
}
function testLocaldaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'localday2', $day );
}
# month
/** @dataProvider MediaWikiProvide::Months */
# month
/** @dataProvider MediaWikiProvide::Months */
function testRevisiondaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'revisionday2', $day );
}
function testRevisiondaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'revisionday2', $day );
}
# revision month
/** @dataProvider MediaWikiProvide::Months */
# revision month
/** @dataProvider MediaWikiProvide::Months */
/**
* Main assertion helper for magic variables padding
/**
* 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 $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; }
*/
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 )
);
$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 );
//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 */
}
/** helper to set the parser timestamp and revision timestamp */
protected $file = false;
protected function setUp() {
protected $file = false;
protected function setUp() {
- global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
+ global $wgContLang, $wgLanguageCode;
+ global $wgNamespaceProtection, $wgNamespaceAliases;
+
+ $wgLanguageCode = 'en';
$wgContLang = Language::factory( 'en' );
//Setup CLI arguments
$wgContLang = Language::factory( 'en' );
//Setup CLI arguments