Merge "API: Fix parameter validation in setnotificationtimestamp"
[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 function testFormatNum() {
10 $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) );
11 $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) );
12 }
13
14 /**
15 * Mostly to test the raw ascii feature.
16 * @dataProvider providerSprintfDate
17 */
18 function testSprintfDate( $format, $date, $expected ) {
19 $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
20 }
21
22 function providerSprintfDate() {
23 return array(
24 array(
25 'xg "vs" g',
26 '20120102030410',
27 'يناير vs ٣'
28 ),
29 array(
30 'xmY',
31 '20120102030410',
32 '١٤٣٣'
33 ),
34 array(
35 'xnxmY',
36 '20120102030410',
37 '1433'
38 ),
39 array(
40 'xN xmj xmn xN xmY',
41 '20120102030410',
42 ' 7 2 ١٤٣٣'
43 ),
44 );
45 }
46
47 /** @dataProvider providePlural */
48 function testPlural( $result, $value ) {
49 $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' );
50 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
51 }
52
53 /** @dataProvider providePlural */
54 function testGetPluralRuleType( $result, $value ) {
55 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
56 }
57
58 function providePlural() {
59 return array(
60 array( 'zero', 0 ),
61 array( 'one', 1 ),
62 array( 'two', 2 ),
63 array( 'few', 3 ),
64 array( 'few', 9 ),
65 array( 'few', 110 ),
66 array( 'many', 11 ),
67 array( 'many', 15 ),
68 array( 'many', 99 ),
69 array( 'many', 9999 ),
70 array( 'other', 100 ),
71 array( 'other', 102 ),
72 array( 'other', 1000 ),
73 array( 'other', 1.7 ),
74 );
75 }
76 }