mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-30 19:16:39 +00:00
32069364ff
Use $this->getServiceContainer() instead of MediaWikiServices::getInstance() in maintenance and tests. Change-Id: I4066d7b2029296f1edb164acc5f8c812ccfba808
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\Extension\DiscussionTools\LanguageData;
|
|
use MediaWiki\MainConfigNames;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\DiscussionTools\LanguageData
|
|
*/
|
|
class LanguageDataTest extends IntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideLocalData
|
|
*/
|
|
public function testGetLocalData( string $langCode, array $config, string $expectedPath ): void {
|
|
$config += [
|
|
MainConfigNames::LanguageCode => $langCode,
|
|
MainConfigNames::UsePigLatinVariant => false,
|
|
MainConfigNames::TranslateNumerals => true,
|
|
MainConfigNames::Localtimezone => 'UTC',
|
|
];
|
|
$this->overrideConfigValues( $config );
|
|
|
|
$expectedData = static::getJson( $expectedPath );
|
|
|
|
$services = $this->getServiceContainer();
|
|
$languageData = new LanguageData(
|
|
$services->getMainConfig(),
|
|
$services->getContentLanguage(),
|
|
$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 static 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', [ MainConfigNames::Localtimezone => 'Asia/Bangkok' ], '../cases/datatest-th.json' ],
|
|
// Special page alias with underscores (T327021)
|
|
[ 'hu', [], '../cases/datatest-hu.json' ],
|
|
];
|
|
}
|
|
|
|
}
|