Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / LanguagePlTest.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/LanguagePl.php */
9 class LanguagePlTest extends LanguageClassesTestCase {
10 /**
11 * @dataProvider providePlural
12 * @covers Language::convertPlural
13 */
14 public function testPlural( $result, $value ) {
15 $forms = [ 'one', 'few', 'many' ];
16 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
17 }
18
19 /**
20 * @dataProvider providePlural
21 * @covers Language::getPluralRuleType
22 */
23 public function testGetPluralRuleType( $result, $value ) {
24 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
25 }
26
27 public static function providePlural() {
28 return [
29 [ 'many', 0 ],
30 [ 'one', 1 ],
31 [ 'few', 2 ],
32 [ 'few', 3 ],
33 [ 'few', 4 ],
34 [ 'many', 5 ],
35 [ 'many', 9 ],
36 [ 'many', 10 ],
37 [ 'many', 11 ],
38 [ 'many', 21 ],
39 [ 'few', 22 ],
40 [ 'few', 23 ],
41 [ 'few', 24 ],
42 [ 'many', 25 ],
43 [ 'many', 200 ],
44 [ 'many', 201 ],
45 ];
46 }
47
48 /**
49 * @dataProvider providePluralTwoForms
50 * @covers Language::convertPlural
51 */
52 public function testPluralTwoForms( $result, $value ) {
53 $forms = [ 'one', 'other' ];
54 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
55 }
56
57 public static function providePluralTwoForms() {
58 return [
59 [ 'other', 0 ],
60 [ 'one', 1 ],
61 [ 'other', 2 ],
62 [ 'other', 3 ],
63 [ 'other', 4 ],
64 [ 'other', 5 ],
65 [ 'other', 9 ],
66 [ 'other', 10 ],
67 [ 'other', 11 ],
68 [ 'other', 21 ],
69 [ 'other', 22 ],
70 [ 'other', 23 ],
71 [ 'other', 24 ],
72 [ 'other', 25 ],
73 [ 'other', 200 ],
74 [ 'other', 201 ],
75 ];
76 }
77
78 /**
79 * @covers LanguagePl::commafy()
80 * @dataProvider provideCommafyData
81 */
82 public function testCommafy( $number, $numbersWithCommas ) {
83 $this->assertEquals(
84 $numbersWithCommas,
85 $this->getLang()->commafy( $number ),
86 "commafy('$number')"
87 );
88 }
89
90 public static function provideCommafyData() {
91 // Note that commafy() always uses English separators (',' and '.') instead of
92 // Polish (' ' and ','). There is another function that converts them later.
93 return [
94 [ 1000, '1000' ],
95 [ 10000, '10,000' ],
96 [ 1000.0001, '1000.0001' ],
97 [ 10000.0001, '10,000.0001' ],
98 [ -1000, '-1000' ],
99 [ -10000, '-10,000' ],
100 [ -1000.0001, '-1000.0001' ],
101 [ -10000.0001, '-10,000.0001' ],
102 ];
103 }
104 }