5a66759873f29e7a4051137648fd1b88da4ae1b4
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / LanguageArTest.php
1 <?php
2 /**
3 * Based on LanguagMlTest
4 * @file
5 */
6
7 /** Tests for MediaWiki languages/LanguageAr.php */
8 class LanguageArTest extends LanguageClassesTestCase {
9 /**
10 * @covers Language::formatNum
11 * @todo split into a test and a dataprovider
12 */
13 public function testFormatNum() {
14 $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) );
15 $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) );
16 }
17
18 /**
19 * Mostly to test the raw ascii feature.
20 * @dataProvider providerSprintfDate
21 * @covers Language::sprintfDate
22 */
23 public function testSprintfDate( $format, $date, $expected ) {
24 $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
25 }
26
27 public static function providerSprintfDate() {
28 return [
29 [
30 'xg "vs" g',
31 '20120102030410',
32 'يناير vs ٣'
33 ],
34 [
35 'xmY',
36 '20120102030410',
37 '١٤٣٣'
38 ],
39 [
40 'xnxmY',
41 '20120102030410',
42 '1433'
43 ],
44 [
45 'xN xmj xmn xN xmY',
46 '20120102030410',
47 ' 7 2 ١٤٣٣'
48 ],
49 ];
50 }
51
52 /**
53 * @dataProvider providePlural
54 * @covers Language::convertPlural
55 */
56 public function testPlural( $result, $value ) {
57 $forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ];
58 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
59 }
60
61 /**
62 * @dataProvider providePlural
63 * @covers Language::getPluralRuleType
64 */
65 public function testGetPluralRuleType( $result, $value ) {
66 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
67 }
68
69 public static function providePlural() {
70 return [
71 [ 'zero', 0 ],
72 [ 'one', 1 ],
73 [ 'two', 2 ],
74 [ 'few', 3 ],
75 [ 'few', 9 ],
76 [ 'few', 110 ],
77 [ 'many', 11 ],
78 [ 'many', 15 ],
79 [ 'many', 99 ],
80 [ 'many', 9999 ],
81 [ 'other', 100 ],
82 [ 'other', 102 ],
83 [ 'other', 1000 ],
84 [ 'other', 1.7 ],
85 ];
86 }
87 }