mediawiki-extensions-Discus.../tests/phpunit/DataTest.php
Bartosz Dziewoński a1dc3a4896 Correctly generate timezone abbreviations for parsing
Also, add tests covering this and the previous bug fixes in this code
(T259818, T261706).

Note that the test data added in tests/cases/ doesn't exactly match
the entire configuration of the wiki, only the parts we want to cover.
This is unlike the data in tests/data/, which was literally copied
from the relevant wikis, and which is used as input for other tests.

Bug: T265500
Change-Id: I29a59a5952f6dc9fb5910434bb6bcc9dcdaa01a9
2020-10-15 12:11:25 +00:00

47 lines
1.2 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 );
// Uncomment this to write updated content to the JSON files:
// 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' ],
];
}
}