Merge "Added UserCache::getUserName() convenience function."
[lhc/web/wiklou.git] / tests / phpunit / languages / 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 languages/classes/LanguageHe.php */
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 /** @dataProvider provideTwoPluralForms */
23 function testTwoPluralForms( $result, $value ) {
24 $forms = array( 'one', 'other' );
25 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
26 }
27
28 /** @dataProvider provideThreePluralForms */
29 function testThreePluralForms( $result, $value ) {
30 $forms = array( 'one', 'two', 'other' );
31 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
32 }
33
34 /** @dataProvider provideFourPluralForms */
35 function testFourPluralForms( $result, $value ) {
36 $forms = array( 'one', 'two', 'many', 'other' );
37 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
38 }
39
40 /** @dataProvider provideFourPluralForms */
41 function testGetPluralRuleType( $result, $value ) {
42 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
43 }
44
45 public static function provideTwoPluralForms() {
46 return array (
47 array( 'other', 0 ), // Zero - plural
48 array( 'one', 1 ), // Singular
49 array( 'other', 2 ), // No third form provided, use it as plural
50 array( 'other', 3 ), // Plural - other
51 array( 'other', 10 ), // No fourth form provided, use it as plural
52 array( 'other', 20 ), // No fourth form provided, use it as plural
53 );
54 }
55
56 public static function provideThreePluralForms() {
57 return array (
58 array( 'other', 0 ), // Zero - plural
59 array( 'one', 1 ), // Singular
60 array( 'two', 2 ), // Dual
61 array( 'other', 3 ), // Plural - other
62 array( 'other', 10 ), // No fourth form provided, use it as plural
63 array( 'other', 20 ), // No fourth form provided, use it as plural
64 );
65 }
66
67 public static function provideFourPluralForms() {
68 return array (
69 array( 'other', 0 ), // Zero - plural
70 array( 'one', 1 ), // Singular
71 array( 'two', 2 ), // Dual
72 array( 'other', 3 ), // Plural - other
73 array( 'other', 10 ), // 10 is supposed to be plural (other), not "many"
74 array( 'many', 20 ), // Fourth form provided - rare, but supported by CLDR
75 );
76 }
77
78 /** @dataProvider provideGrammar */
79 function testGrammar( $result, $word, $case ) {
80 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
81 }
82
83 // The comments in the beginning of the line help avoid RTL problems
84 // with text editors.
85 public static function provideGrammar() {
86 return array (
87 array(
88 /* result */ 'וויקיפדיה',
89 /* word */ 'ויקיפדיה',
90 /* case */ 'תחילית',
91 ),
92 array(
93 /* result */ 'וולפגנג',
94 /* word */ 'וולפגנג',
95 /* case */ 'prefixed',
96 ),
97 array(
98 /* result */ 'קובץ',
99 /* word */ 'הקובץ',
100 /* case */ 'תחילית',
101 ),
102 array(
103 /* result */ '־Wikipedia',
104 /* word */ 'Wikipedia',
105 /* case */ 'תחילית',
106 ),
107 array(
108 /* result */ '־1995',
109 /* word */ '1995',
110 /* case */ 'תחילית',
111 ),
112 );
113 }
114 }