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