Move Test files under same folder structure where class is (/languages/)
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / 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 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
37 }
38
39 public static function providePlural() {
40 return array(
41 array( 'one', 1 ),
42 array( 'many', 11 ),
43 array( 'one', 91 ),
44 array( 'one', 121 ),
45 array( 'few', 2 ),
46 array( 'few', 3 ),
47 array( 'few', 4 ),
48 array( 'few', 334 ),
49 array( 'many', 5 ),
50 array( 'many', 15 ),
51 array( 'many', 120 ),
52 );
53 }
54
55 /**
56 * @dataProvider providePluralTwoForms
57 * @covers Language::convertPlural
58 */
59 public function testPluralTwoForms( $result, $value ) {
60 $forms = array( '1=one', 'other' );
61 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
62 }
63
64 public static function providePluralTwoForms() {
65 return array(
66 array( 'one', 1 ),
67 array( 'other', 11 ),
68 array( 'other', 91 ),
69 array( 'other', 121 ),
70 );
71 }
72
73 /**
74 * @dataProvider providerGrammar
75 * @covers Language::convertGrammar
76 */
77 public function testGrammar( $result, $word, $case ) {
78 $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
79 }
80
81 public static function providerGrammar() {
82 return array(
83 array(
84 'Википедии',
85 'Википедия',
86 'genitive',
87 ),
88 array(
89 'Викитеки',
90 'Викитека',
91 'genitive',
92 ),
93 array(
94 'Викитеке',
95 'Викитека',
96 'prepositional',
97 ),
98 array(
99 'Викисклада',
100 'Викисклад',
101 'genitive',
102 ),
103 array(
104 'Викискладе',
105 'Викисклад',
106 'prepositional',
107 ),
108 array(
109 'Викиданных',
110 'Викиданные',
111 'prepositional',
112 ),
113 );
114 }
115 }