mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-25 08:50:22 +00:00
a29c49ae70
Use an environment variable "DISCUSSIONTOOLS_OVERWRITE_TESTS". Change-Id: I017112b7d6b1df9497f01f3f97f34e0935ca16f8
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use HashConfig;
|
|
use MediaWiki\Extension\DiscussionTools\Data;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\DiscussionTools\Data
|
|
*/
|
|
class DataTest extends CommentTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideLocalData
|
|
* @covers ::getLocalData
|
|
*/
|
|
public function testGetLocalData( string $langCode, array $config, string $expectedPath ) : void {
|
|
$conf = new HashConfig( $config + [
|
|
'ContentLanguage' => $langCode,
|
|
'TranslateNumerals' => true,
|
|
'Localtimezone' => 'UTC',
|
|
] );
|
|
$expectedData = self::getJson( $expectedPath );
|
|
|
|
$data = Data::getLocalData( null, $conf, $langCode );
|
|
|
|
// Optionally write updated content to the JSON files
|
|
if ( getenv( 'DISCUSSIONTOOLS_OVERWRITE_TESTS' ) ) {
|
|
self::overwriteJsonFile( $expectedPath, $data );
|
|
}
|
|
|
|
self::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' ],
|
|
];
|
|
}
|
|
|
|
}
|