Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / languages / classes / LanguageHeTest.php
blobc1b774af512622f0a5799a78d3f84b6c5387912c
1 <?php
2 /**
3 * @author Amir E. Aharoni
4 * @copyright Copyright © 2012, Amir E. Aharoni
5 * @file
6 */
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.
22 // @todo the below test*PluralForms test methods can be refactored
23 // to use a single test method and data provider..
25 /**
26 * @dataProvider provideTwoPluralForms
27 * @covers Language::convertPlural
29 public function testTwoPluralForms( $result, $value ) {
30 $forms = [ 'one', 'other' ];
31 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
34 /**
35 * @dataProvider provideThreePluralForms
36 * @covers Language::convertPlural
38 public function testThreePluralForms( $result, $value ) {
39 $forms = [ 'one', 'two', 'other' ];
40 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
43 /**
44 * @dataProvider provideFourPluralForms
45 * @covers Language::convertPlural
47 public function testFourPluralForms( $result, $value ) {
48 $forms = [ 'one', 'two', 'many', 'other' ];
49 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
52 /**
53 * @dataProvider provideFourPluralForms
54 * @covers Language::convertPlural
56 public function testGetPluralRuleType( $result, $value ) {
57 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
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
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
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
93 /**
94 * @dataProvider provideGrammar
95 * @covers Language::convertGrammar
97 public function testGrammar( $result, $word, $case ) {
98 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
101 // The comments in the beginning of the line help avoid RTL problems
102 // with text editors.
103 public static function provideGrammar() {
104 return [
106 /* result */'וויקיפדיה',
107 /* word */'ויקיפדיה',
108 /* case */'תחילית',
111 /* result */'וולפגנג',
112 /* word */'וולפגנג',
113 /* case */'prefixed',
116 /* result */'קובץ',
117 /* word */'הקובץ',
118 /* case */'תחילית',
121 /* result */'־Wikipedia',
122 /* word */'Wikipedia',
123 /* case */'תחילית',
126 /* result */'־1995',
127 /* word */'1995',
128 /* case */'תחילית',