Debian Codegraph @

tests/phpunit/includes/languages/LanguageHeTest.php

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