summaryrefslogtreecommitdiff
path: root/tests/phpunit/languages/LanguageArTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-09-04 05:51:59 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-09-04 05:51:59 +0200
commit91e194556c52d2f354344f930419eef2dd6267f0 (patch)
tree0cd12490d3cd3499274017c9b799d0f738d3719e /tests/phpunit/languages/LanguageArTest.php
parent08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (diff)
Update to MediaWiki 1.21.2
Diffstat (limited to 'tests/phpunit/languages/LanguageArTest.php')
-rw-r--r--tests/phpunit/languages/LanguageArTest.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/phpunit/languages/LanguageArTest.php b/tests/phpunit/languages/LanguageArTest.php
new file mode 100644
index 00000000..523ee7f6
--- /dev/null
+++ b/tests/phpunit/languages/LanguageArTest.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Based on LanguagMlTest
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageAr.php */
+class LanguageArTest extends LanguageClassesTestCase {
+
+ function testFormatNum() {
+ $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) );
+ $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) );
+ }
+
+ /**
+ * Mostly to test the raw ascii feature.
+ * @dataProvider providerSprintfDate
+ */
+ function testSprintfDate( $format, $date, $expected ) {
+ $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
+ }
+
+ function providerSprintfDate() {
+ return array(
+ array(
+ 'xg "vs" g',
+ '20120102030410',
+ 'يناير vs ٣'
+ ),
+ array(
+ 'xmY',
+ '20120102030410',
+ '١٤٣٣'
+ ),
+ array(
+ 'xnxmY',
+ '20120102030410',
+ '1433'
+ ),
+ array(
+ 'xN xmj xmn xN xmY',
+ '20120102030410',
+ ' 7 2 ١٤٣٣'
+ ),
+ );
+ }
+
+ /** @dataProvider providePlural */
+ function testPlural( $result, $value ) {
+ $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' );
+ $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
+ }
+
+ function providePlural() {
+ return array(
+ array( 'zero', 0 ),
+ array( 'one', 1 ),
+ array( 'two', 2 ),
+ array( 'few', 3 ),
+ array( 'few', 9 ),
+ array( 'few', 110 ),
+ array( 'many', 11 ),
+ array( 'many', 15 ),
+ array( 'many', 99 ),
+ array( 'many', 9999 ),
+ array( 'other', 100 ),
+ array( 'other', 102 ),
+ array( 'other', 1000 ),
+ array( 'other', 1.7 ),
+ );
+ }
+}