Merge "Added "maxPartitionsTry" option to JobQueueFederated"
[lhc/web/wiklou.git] / tests / phpunit / languages / 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 array(
29 array(
30 'xg "vs" g',
31 '20120102030410',
32 'يناير vs ٣'
33 ),
34 array(
35 'xmY',
36 '20120102030410',
37 '١٤٣٣'
38 ),
39 array(
40 'xnxmY',
41 '20120102030410',
42 '1433'
43 ),
44 array(
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 = array( '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 array(
71 array( 'zero', 0 ),
72 array( 'one', 1 ),
73 array( 'two', 2 ),
74 array( 'few', 3 ),
75 array( 'few', 9 ),
76 array( 'few', 110 ),
77 array( 'many', 11 ),
78 array( 'many', 15 ),
79 array( 'many', 99 ),
80 array( 'many', 9999 ),
81 array( 'other', 100 ),
82 array( 'other', 102 ),
83 array( 'other', 1000 ),
84 array( 'other', 1.7 ),
85 );
86 }
87 }