mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-25 06:14:04 +00:00
dac09416fd
MediaWiki default changed in Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38. Change-Id: Ib1eb4b218c89d2a6ce8b82aeec2ee19aca8ff4a9
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\Extension\DiscussionTools\LanguageData;
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\DiscussionTools\LanguageData
|
|
*/
|
|
class LanguageDataTest extends IntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideLocalData
|
|
*/
|
|
public function testGetLocalData( string $langCode, array $config, string $expectedPath ): void {
|
|
$config += [
|
|
'ContentLanguage' => $langCode,
|
|
'UsePigLatinVariant' => false,
|
|
'TranslateNumerals' => true,
|
|
'Localtimezone' => 'UTC',
|
|
];
|
|
$this->overrideConfigValues( $config );
|
|
|
|
$expectedData = static::getJson( $expectedPath );
|
|
|
|
$services = MediaWikiServices::getInstance();
|
|
$languageData = new LanguageData(
|
|
$services->getMainConfig(),
|
|
$services->getLanguageFactory()->getLanguage( $langCode ),
|
|
$services->getLanguageConverterFactory(),
|
|
$services->getSpecialPageFactory()
|
|
);
|
|
|
|
$data = $languageData->getLocalData();
|
|
|
|
// Optionally write updated content to the JSON files
|
|
if ( getenv( 'DISCUSSIONTOOLS_OVERWRITE_TESTS' ) ) {
|
|
static::overwriteJsonFile( $expectedPath, $data );
|
|
}
|
|
|
|
static::assertEquals( $expectedData, $data );
|
|
}
|
|
|
|
public function provideLocalData(): array {
|
|
return [
|
|
// Boring
|
|
[ 'en', [], '../cases/datatest-en.json' ],
|
|
// Has language variants (T259818)
|
|
[ 'sr', [], '../cases/datatest-sr.json' ],
|
|
// Has localised digits (T261706)
|
|
[ 'ckb', [], '../cases/datatest-ckb.json' ],
|
|
// Has unusual timezone abbreviation (T265500)
|
|
[ 'th', [ 'Localtimezone' => 'Asia/Bangkok' ], '../cases/datatest-th.json' ],
|
|
];
|
|
}
|
|
|
|
}
|