Merge "Don't allow completing a partial stash upload"
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / LanguageHeTest.php
1 <?php
2 /**
3 * @author Amir E. Aharoni
4 * @copyright Copyright © 2012, Amir E. Aharoni
5 * @file
6 */
7
8 /** Tests for MediaWiki Hebrew grammar transformation handling */
9 class LanguageHeTest extends LanguageClassesTestCase {
10 /**
11 * The most common usage for the plural forms is two forms,
12 * for singular and plural. In this case, the second form
13 * is technically dual, but in practice it's used as plural.
14 * In some cases, usually with expressions of time, three forms
15 * are needed - singular, dual and plural.
16 * CLDR also specifies a fourth form for multiples of 10,
17 * which is very rare. It also has a mistake, because
18 * the number 10 itself is supposed to be just plural,
19 * so currently it's overridden in MediaWiki.
20 */
21
22 // @todo the below test*PluralForms test methods can be refactored
23 // to use a single test method and data provider..
24
25 /**
26 * @dataProvider provideTwoPluralForms
27 * @covers Language::convertPlural
28 */
29 public function testTwoPluralForms( $result, $value ) {
30 $forms = [ 'one', 'other' ];
31 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
32 }
33
34 /**
35 * @dataProvider provideThreePluralForms
36 * @covers Language::convertPlural
37 */
38 public function testThreePluralForms( $result, $value ) {
39 $forms = [ 'one', 'two', 'other' ];
40 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
41 }
42
43 /**
44 * @dataProvider provideFourPluralForms
45 * @covers Language::convertPlural
46 */
47 public function testFourPluralForms( $result, $value ) {
48 $forms = [ 'one', 'two', 'many', 'other' ];
49 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
50 }
51
52 /**
53 * @dataProvider provideFourPluralForms
54 * @covers Language::convertPlural
55 */
56 public function testGetPluralRuleType( $result, $value ) {
57 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
58 }
59
60 public static function provideTwoPluralForms() {
61 return [
62 [ 'other', 0 ], // Zero - plural
63 [ 'one', 1 ], // Singular
64 [ 'other', 2 ], // No third form provided, use it as plural
65 [ 'other', 3 ], // Plural - other
66 [ 'other', 10 ], // No fourth form provided, use it as plural
67 [ 'other', 20 ], // No fourth form provided, use it as plural
68 ];
69 }
70
71 public static function provideThreePluralForms() {
72 return [
73 [ 'other', 0 ], // Zero - plural
74 [ 'one', 1 ], // Singular
75 [ 'two', 2 ], // Dual
76 [ 'other', 3 ], // Plural - other
77 [ 'other', 10 ], // No fourth form provided, use it as plural
78 [ 'other', 20 ], // No fourth form provided, use it as plural
79 ];
80 }
81
82 public static function provideFourPluralForms() {
83 return [
84 [ 'other', 0 ], // Zero - plural
85 [ 'one', 1 ], // Singular
86 [ 'two', 2 ], // Dual
87 [ 'other', 3 ], // Plural - other
88 [ 'other', 10 ], // 10 is supposed to be plural (other), not "many"
89 [ 'many', 20 ], // Fourth form provided - rare, but supported by CLDR
90 ];
91 }
92
93 /**
94 * @dataProvider provideGrammar
95 * @covers Language::convertGrammar
96 */
97 public function testGrammar( $result, $word, $case ) {
98 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
99 }
100
101 // The comments in the beginning of the line help avoid RTL problems
102 // with text editors.
103 public static function provideGrammar() {
104 return [
105 [
106 /* result */'וויקיפדיה',
107 /* word */'ויקיפדיה',
108 /* case */'תחילית',
109 ],
110 [
111 /* result */'וולפגנג',
112 /* word */'וולפגנג',
113 /* case */'prefixed',
114 ],
115 [
116 /* result */'קובץ',
117 /* word */'הקובץ',
118 /* case */'תחילית',
119 ],
120 [
121 /* result */'־Wikipedia',
122 /* word */'Wikipedia',
123 /* case */'תחילית',
124 ],
125 [
126 /* result */'־1995',
127 /* word */'1995',
128 /* case */'תחילית',
129 ],
130 ];
131 }
132 }