blob: 0d3e19c60238c585e6cfa8c4d75db329d3695502 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
/**
* @group Database
* @covers TranslationAidDataProvider
*/
class TranslationAidDataProviderTest extends MediaWikiIntegrationTestCase {
protected function setUp() : void {
parent::setUp();
$this->setMwGlobals( [
'wgTranslateMessageNamespaces' => [ NS_MEDIAWIKI ]
] );
$this->setTemporaryHook( 'TranslatePostInitGroups', [ $this, 'getTestGroups' ] );
$mg = MessageGroups::singleton();
$mg->setCache( new WANObjectCache( [ 'cache' => ObjectCache::getInstance( 'hash' ) ] ) );
$mg->recache();
MessageIndex::setInstance( new HashMessageIndex() );
MessageIndex::singleton()->rebuild();
}
public function getTestGroups( &$list ) {
$messages = [
'TestPage' => 'bunny',
];
$list['test-group'] = new MockWikiMessageGroup( 'test-group', $messages );
return false;
}
/**
* @covers TranslationAidDataProvider::getGoodTranslations
* @throws MWException
*/
public function testGetGoodTranslations() {
$title = 'MediaWiki:TestPage';
// Create some translations
$this->assertTrue(
$this->editPage( $title . '/fi', 'Test Finnish Translation' )->isGood(),
'Sanity: must successfully edit ' . $title . '/fi page'
);
$this->assertTrue(
$this->editPage( $title . '/ru', 'Test Russian Translation' )->isGood(),
'Sanity: must successfully edit ' . $title . '/ru page'
);
$messageHandle = new MessageHandle( Title::newFromText( $title ) );
$this->assertTrue( $messageHandle->isValid(), 'Sanity: MessageHandle must be valid' );
$dataProvider = new TranslationAidDataProvider( $messageHandle );
$this->assertEquals( [
'ru' => 'Test Russian Translation',
'fi' => 'Test Finnish Translation'
], $dataProvider->getGoodTranslations() );
}
}
|