| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class LanguageArTest extends LanguageClassesTestCase { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public function testFormatNum( $num, $formatted ) { |
| 14 |
$this->assertEquals( $formatted, $this->getLang()->formatNum( $num ) ); |
| 15 |
} |
| 16 |
|
| 17 |
public static function provideFormatNum() { |
| 18 |
return [ |
| 19 |
[ '1234567', '١٬٢٣٤٬٥٦٧' ], |
| 20 |
[ -12.89, '−١٢٫٨٩' ], |
| 21 |
[ '1289.456', '١٬٢٨٩٫٤٥٦' ] |
| 22 |
]; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function testNormalize( $input, $expected ) { |
| 31 |
if ( $input === $expected ) { |
| 32 |
$this->fail( 'Expected output must differ.' ); |
| 33 |
} |
| 34 |
|
| 35 |
$this->assertSame( |
| 36 |
$expected, |
| 37 |
$this->getLang()->normalize( $input ), |
| 38 |
'ar-normalised form' |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
public static function provideNormalize() { |
| 43 |
return [ |
| 44 |
[ |
| 45 |
'ﷅ', |
| 46 |
'صمم', |
| 47 |
], |
| 48 |
[ |
| 49 |
'ﻴ', |
| 50 |
'ي', |
| 51 |
], |
| 52 |
[ |
| 53 |
'ﻬ', |
| 54 |
'ه', |
| 55 |
], |
| 56 |
]; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public function testSprintfDate( $format, $date, $expected ) { |
| 65 |
$this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) ); |
| 66 |
} |
| 67 |
|
| 68 |
public static function provideSprintfDate() { |
| 69 |
return [ |
| 70 |
[ |
| 71 |
'xg "vs" g', |
| 72 |
'20120102030410', |
| 73 |
'يناير vs ٣' |
| 74 |
], |
| 75 |
[ |
| 76 |
'xmY', |
| 77 |
'20120102030410', |
| 78 |
'١٤٣٣' |
| 79 |
], |
| 80 |
[ |
| 81 |
'xnxmY', |
| 82 |
'20120102030410', |
| 83 |
'1433' |
| 84 |
], |
| 85 |
[ |
| 86 |
'xN xmj xmn xN xmY', |
| 87 |
'20120102030410', |
| 88 |
' 7 2 ١٤٣٣' |
| 89 |
], |
| 90 |
]; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public function testPlural( $result, $value ) { |
| 98 |
$forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ]; |
| 99 |
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
public function testGetPluralRuleType( $result, $value ) { |
| 107 |
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); |
| 108 |
} |
| 109 |
|
| 110 |
public static function providePlural() { |
| 111 |
return [ |
| 112 |
[ 'zero', 0 ], |
| 113 |
[ 'one', 1 ], |
| 114 |
[ 'two', 2 ], |
| 115 |
[ 'few', 3 ], |
| 116 |
[ 'few', 9 ], |
| 117 |
[ 'few', 110 ], |
| 118 |
[ 'many', 11 ], |
| 119 |
[ 'many', 15 ], |
| 120 |
[ 'many', 99 ], |
| 121 |
[ 'many', 9999 ], |
| 122 |
[ 'other', 100 ], |
| 123 |
[ 'other', 102 ], |
| 124 |
[ 'other', 1000 ], |
| 125 |
[ 'other', 1.7 ], |
| 126 |
]; |
| 127 |
} |
| 128 |
} |