aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/language/converters/ZhConverterTest.php
blob: b7f697757c917e93536ec6ba3626b424dd675bab (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

/**
 * @group Language
 * @covers \ZhConverter
 */
class ZhConverterTest extends MediaWikiIntegrationTestCase {

	use LanguageConverterTestTrait;

	/**
	 * @dataProvider provideAutoConvertToAllVariants
	 */
	public function testAutoConvertToAllVariants( $result, $value ) {
		$this->assertEquals( $result,
			$this->getLanguageConverter()->autoConvertToAllVariants( $value ) );
	}

	public static function provideAutoConvertToAllVariants() {
		return [
			// Plain hant -> hans
			[
				[
					'zh'      => '㑯',
					'zh-hans' => '㑔',
					'zh-hant' => '㑯',
					'zh-cn'   => '㑔',
					'zh-hk'   => '㑯',
					'zh-mo'   => '㑯',
					'zh-my'   => '㑔',
					'zh-sg'   => '㑔',
					'zh-tw'   => '㑯',
				],
				'㑯'
			],
			// Plain hans -> hant
			[
				[
					'zh'      => '㐷',
					'zh-hans' => '㐷',
					'zh-hant' => '傌',
					'zh-cn'   => '㐷',
					'zh-hk'   => '傌',
					'zh-mo'   => '傌',
					'zh-my'   => '㐷',
					'zh-sg'   => '㐷',
					'zh-tw'   => '傌',
				],
				'㐷'
			],
			// zh-cn specific
			[
				[
					'zh'      => '仲介',
					'zh-hans' => '仲介',
					'zh-hant' => '仲介',
					'zh-cn'   => '中介',
					'zh-hk'   => '仲介',
					'zh-mo'   => '仲介',
					'zh-my'   => '中介',
					'zh-sg'   => '中介',
					'zh-tw'   => '仲介',
				],
				'仲介'
			],
			// zh-hk specific
			[
				[
					'zh'      => '中文里',
					'zh-hans' => '中文里',
					'zh-hant' => '中文裡',
					'zh-cn'   => '中文里',
					'zh-hk'   => '中文裏',
					'zh-mo'   => '中文裏',
					'zh-my'   => '中文里',
					'zh-sg'   => '中文里',
					'zh-tw'   => '中文裡',
				],
				'中文里'
			],
			// zh-tw specific
			[
				[
					'zh'      => '甲肝',
					'zh-hans' => '甲肝',
					'zh-hant' => '甲肝',
					'zh-cn'   => '甲肝',
					'zh-hk'   => '甲肝',
					'zh-mo'   => '甲肝',
					'zh-my'   => '甲肝',
					'zh-sg'   => '甲肝',
					'zh-tw'   => 'A肝',
				],
				'甲肝'
			],
			// zh-tw overrides zh-hant
			[
				[
					'zh'      => '账',
					'zh-hans' => '账',
					'zh-hant' => '賬',
					'zh-cn'   => '账',
					'zh-hk'   => '賬',
					'zh-mo'   => '賬',
					'zh-my'   => '账',
					'zh-sg'   => '账',
					'zh-tw'   => '帳',
				],
				'账'
			],
			// zh-hk overrides zh-hant
			[
				[
					'zh'      => '一地里',
					'zh-hans' => '一地里',
					'zh-hant' => '一地裡',
					'zh-cn'   => '一地里',
					'zh-hk'   => '一地裏',
					'zh-mo'   => '一地裏',
					'zh-my'   => '一地里',
					'zh-sg'   => '一地里',
					'zh-tw'   => '一地裡',
				],
				'一地里'
			],
		];
	}
}