Allow the retrieval of the plural rule type for a given number
[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 /** @dataProvider providePlural */
12 function testPlural( $result, $value ) {
13 $forms = array( 'one', 'few', 'many', 'other' );
14 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
15 }
16
17 /** @dataProvider providePlural */
18 function testGetPluralRuleType( $result, $value ) {
19 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
20 }
21
22 function providePlural() {
23 return array (
24 array( 'one', 1 ),
25 array( 'many', 11 ),
26 array( 'one', 91 ),
27 array( 'one', 121 ),
28 array( 'few', 2 ),
29 array( 'few', 3 ),
30 array( 'few', 4 ),
31 array( 'few', 334 ),
32 array( 'many', 5 ),
33 array( 'many', 15 ),
34 array( 'many', 120 ),
35 );
36 }
37
38 /** @dataProvider providePluralTwoForms */
39 function testPluralTwoForms( $result, $value ) {
40 $forms = array( 'one', 'other' );
41 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
42 }
43
44 function providePluralTwoForms() {
45 return array(
46 array( 'one', 1 ),
47 array( 'other', 11 ),
48 array( 'other', 91 ),
49 array( 'other', 121 ),
50 );
51 }
52
53 /** @dataProvider providerGrammar */
54 function testGrammar( $result, $word, $case ) {
55 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
56 }
57
58 function providerGrammar() {
59 return array(
60 array(
61 'Википедии',
62 'Википедия',
63 'genitive',
64 ),
65 array(
66 'Викитеки',
67 'Викитека',
68 'genitive',
69 ),
70 array(
71 'Викитеке',
72 'Викитека',
73 'prepositional',
74 ),
75 array(
76 'Викиданных',
77 'Викиданные',
78 'prepositional',
79 ),
80 );
81 }
82 }