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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<?php
/**
* @file
* @author Santhosh Thottingal
* @copyright Copyright © 2012-2013, Santhosh Thottingal
* @license GPL-2.0-or-later
*/
class ExclusionInclusionListTest extends MediaWikiTestCase {
/** @var MessageGroup */
protected $group;
protected $codes;
protected $groupConfiguration = [
'BASIC' => [
'class' => FileBasedMessageGroup::class,
'id' => 'test-id',
'label' => 'Test Label',
'namespace' => 'NS_MEDIAWIKI',
'description' => 'Test description',
],
'FILES' => [
'class' => TestFFS::class,
],
];
protected function setUp(): void {
parent::setUp();
$this->group = MessageGroupBase::factory( $this->groupConfiguration );
$this->codes = array_flip( array_keys( TranslateUtils::getLanguageNames( 'en' ) ) );
}
protected function tearDown(): void {
unset( $this->group );
parent::tearDown();
}
public function testNoLanguageConf() {
$translatableLanguages = $this->group->getTranslatableLanguages();
$this->assertNull( $translatableLanguages );
}
public function testAllExclusionList() {
$conf = $this->groupConfiguration;
$conf['LANGUAGES'] = [
'blacklist' => '*',
];
$group = MessageGroupBase::factory( $conf );
$translatableLanguages = $group->getTranslatableLanguages();
$this->assertEquals( count( $translatableLanguages ), 0 );
}
public function testAllInclusionList() {
$conf = $this->groupConfiguration;
$conf['LANGUAGES'] = [
'whitelist' => '*',
];
$group = MessageGroupBase::factory( $conf );
$translatableLanguages = $group->getTranslatableLanguages();
$this->assertNull( $translatableLanguages );
}
public function testInclusionListOverridesExclusionList() {
$conf = $this->groupConfiguration;
$conf['LANGUAGES'] = [
'whitelist' => [ 'en', 'hi', 'ta' ],
'blacklist' => [ 'ta' ],
];
$group = MessageGroupBase::factory( $conf );
$translatableLanguages = $group->getTranslatableLanguages();
$this->assertTrue( isset( $translatableLanguages['ta'] ) );
$this->assertTrue( isset( $translatableLanguages['hi'] ) );
}
public function testSomeExclusionList() {
$conf = $this->groupConfiguration;
$conf['LANGUAGES'] = [
'blacklist' => [ 'or', 'hi' ],
];
$group = MessageGroupBase::factory( $conf );
$translatableLanguages = $group->getTranslatableLanguages();
$this->assertTrue( !isset( $translatableLanguages['hi'] ) );
$this->assertTrue( isset( $translatableLanguages['he'] ) );
}
}
|