Merge "Update plural rules to CLDR 24"
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageRuTest.php
1 <?php
2 /**
3 * @author Amir E. Aharoni
4 * based on LanguageBe_tarask.php
5 * @copyright Copyright © 2012, Amir E. Aharoni
6 * @file
7 */
8
9 /** Tests for MediaWiki languages/classes/LanguageRu.php */
10 class LanguageRuTest extends LanguageClassesTestCase {
11 /**
12 * @dataProvider providePlural
13 * @covers Language::convertPlural
14 */
15 public function testPlural( $result, $value ) {
16 $forms = array( 'one', 'few', 'many', 'other' );
17 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
18 }
19
20 /**
21 * Test explicit plural forms - n=FormN forms
22 * @covers Language::convertPlural
23 */
24 public function testExplicitPlural() {
25 $forms = array( 'one', 'few', 'many', 'other', '12=dozen' );
26 $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) );
27 $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' );
28 $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) );
29 }
30
31 /**
32 * @dataProvider providePlural
33 * @covers Language::getPluralRuleType
34 */
35 public function testGetPluralRuleType( $result, $value ) {
36 // TODO: Remove after MW plurals rules made in sync with CLDR
37 $this->markTestSkipped( 'Skipping. Russian plural forms are overridden in MW' );
38 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
39 }
40
41 public static function providePlural() {
42 return array(
43 array( 'one', 1 ),
44 array( 'many', 11 ),
45 array( 'one', 91 ),
46 array( 'one', 121 ),
47 array( 'few', 2 ),
48 array( 'few', 3 ),
49 array( 'few', 4 ),
50 array( 'few', 334 ),
51 array( 'many', 5 ),
52 array( 'many', 15 ),
53 array( 'many', 120 ),
54 );
55 }
56
57 /**
58 * @dataProvider providePluralTwoForms
59 * @covers Language::convertPlural
60 */
61 public function testPluralTwoForms( $result, $value ) {
62 $forms = array( 'one', 'other' );
63 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
64 }
65
66 public static function providePluralTwoForms() {
67 return array(
68 array( 'one', 1 ),
69 array( 'other', 11 ),
70 array( 'other', 91 ),
71 array( 'other', 121 ),
72 );
73 }
74
75 /**
76 * @dataProvider providerGrammar
77 * @covers Language::convertGrammar
78 */
79 public function testGrammar( $result, $word, $case ) {
80 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
81 }
82
83 public static function providerGrammar() {
84 return array(
85 array(
86 'Википедии',
87 'Википедия',
88 'genitive',
89 ),
90 array(
91 'Викитеки',
92 'Викитека',
93 'genitive',
94 ),
95 array(
96 'Викитеке',
97 'Викитека',
98 'prepositional',
99 ),
100 array(
101 'Викиданных',
102 'Викиданные',
103 'prepositional',
104 ),
105 );
106 }
107 }