2012-01-02 10:41:58 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
2017-12-28 08:24:40 +00:00
|
|
|
|
/**
|
2021-07-31 21:23:21 +00:00
|
|
|
|
* @group Language
|
2017-12-28 08:24:40 +00:00
|
|
|
|
* @covers LanguageAr
|
|
|
|
|
|
*/
|
2012-10-23 20:53:17 +00:00
|
|
|
|
class LanguageArTest extends LanguageClassesTestCase {
|
2018-08-01 18:49:22 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers Language::formatNum
|
2018-08-01 18:49:22 +00:00
|
|
|
|
* @dataProvider provideFormatNum
|
2013-10-22 10:32:29 +00:00
|
|
|
|
*/
|
2018-08-01 18:49:22 +00:00
|
|
|
|
public function testFormatNum( $num, $formatted ) {
|
|
|
|
|
|
$this->assertEquals( $formatted, $this->getLang()->formatNum( $num ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function provideFormatNum() {
|
|
|
|
|
|
return [
|
|
|
|
|
|
[ '1234567', '١٬٢٣٤٬٥٦٧' ],
|
2020-10-21 13:57:50 +00:00
|
|
|
|
[ -12.89, '−١٢٫٨٩' ],
|
2017-06-02 08:42:28 +00:00
|
|
|
|
[ '1289.456', '١٬٢٨٩٫٤٥٦' ]
|
2018-08-01 18:49:22 +00:00
|
|
|
|
];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageAr::normalize
|
|
|
|
|
|
* @covers Language::normalize
|
|
|
|
|
|
* @dataProvider provideNormalize
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testNormalize( $input, $expected ) {
|
|
|
|
|
|
if ( $input === $expected ) {
|
|
|
|
|
|
throw new Exception( 'Expected output must differ.' );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-06 08:47:10 +00:00
|
|
|
|
$this->assertSame(
|
|
|
|
|
|
$expected,
|
|
|
|
|
|
$this->getLang()->normalize( $input ),
|
|
|
|
|
|
'ar-normalised form'
|
|
|
|
|
|
);
|
2018-08-01 18:49:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function provideNormalize() {
|
|
|
|
|
|
return [
|
|
|
|
|
|
[
|
|
|
|
|
|
'ﷅ',
|
|
|
|
|
|
'صمم',
|
|
|
|
|
|
],
|
2020-02-06 08:47:10 +00:00
|
|
|
|
[
|
|
|
|
|
|
'ﻴ',
|
|
|
|
|
|
'ي',
|
|
|
|
|
|
],
|
|
|
|
|
|
[
|
|
|
|
|
|
'ﻬ',
|
|
|
|
|
|
'ه',
|
|
|
|
|
|
],
|
2018-08-01 18:49:22 +00:00
|
|
|
|
];
|
2012-01-02 10:41:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Mostly to test the raw ascii feature.
|
2018-08-01 18:49:22 +00:00
|
|
|
|
* @dataProvider provideSprintfDate
|
2013-10-22 10:32:29 +00:00
|
|
|
|
* @covers Language::sprintfDate
|
2012-01-02 10:41:58 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
public function testSprintfDate( $format, $date, $expected ) {
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
|
2012-01-02 10:41:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-01 18:49:22 +00:00
|
|
|
|
public static function provideSprintfDate() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[
|
2012-01-02 10:41:58 +00:00
|
|
|
|
'xg "vs" g',
|
|
|
|
|
|
'20120102030410',
|
|
|
|
|
|
'يناير vs ٣'
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2012-01-02 10:41:58 +00:00
|
|
|
|
'xmY',
|
|
|
|
|
|
'20120102030410',
|
|
|
|
|
|
'١٤٣٣'
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2012-01-02 10:41:58 +00:00
|
|
|
|
'xnxmY',
|
|
|
|
|
|
'20120102030410',
|
|
|
|
|
|
'1433'
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2012-01-02 10:41:58 +00:00
|
|
|
|
'xN xmj xmn xN xmY',
|
|
|
|
|
|
'20120102030410',
|
|
|
|
|
|
' 7 2 ١٤٣٣'
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
];
|
2012-01-02 10:41:58 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testPlural( $result, $value ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ];
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-01-27 06:01:43 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::getPluralRuleType
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testGetPluralRuleType( $result, $value ) {
|
2013-01-25 01:10:37 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
|
public static function providePlural() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[ 'zero', 0 ],
|
|
|
|
|
|
[ 'one', 1 ],
|
|
|
|
|
|
[ 'two', 2 ],
|
|
|
|
|
|
[ 'few', 3 ],
|
|
|
|
|
|
[ 'few', 9 ],
|
|
|
|
|
|
[ 'few', 110 ],
|
|
|
|
|
|
[ 'many', 11 ],
|
|
|
|
|
|
[ 'many', 15 ],
|
|
|
|
|
|
[ 'many', 99 ],
|
|
|
|
|
|
[ 'many', 9999 ],
|
|
|
|
|
|
[ 'other', 100 ],
|
|
|
|
|
|
[ 'other', 102 ],
|
|
|
|
|
|
[ 'other', 1000 ],
|
|
|
|
|
|
[ 'other', 1.7 ],
|
|
|
|
|
|
];
|
2012-01-27 06:01:43 +00:00
|
|
|
|
}
|
2012-01-02 10:41:58 +00:00
|
|
|
|
}
|