mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-24 13:55:04 +00:00
fcdabc5fcc
Many methods are covered indirectly, and using method-level @covers filters means these are reported as not being covered. Change-Id: I94eb3e8c48209ff0b6bfc09e18c93555bb167e8f
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use HashConfig;
|
|
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 {
|
|
$conf = new HashConfig( $config + [
|
|
'ContentLanguage' => $langCode,
|
|
'TranslateNumerals' => true,
|
|
'Localtimezone' => 'UTC',
|
|
] );
|
|
$expectedData = static::getJson( $expectedPath );
|
|
|
|
$services = MediaWikiServices::getInstance();
|
|
$languageData = new LanguageData(
|
|
$conf,
|
|
MediaWikiServices::getInstance()->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' ],
|
|
];
|
|
}
|
|
|
|
}
|