aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--languages/Language.php2
-rw-r--r--languages/classes/LanguageAr.php2
-rw-r--r--languages/classes/LanguageMl.php2
-rw-r--r--tests/phpunit/languages/classes/LanguageArTest.php49
-rw-r--r--tests/phpunit/languages/classes/LanguageMlTest.php32
-rw-r--r--tests/phpunit/suite.xml2
6 files changed, 73 insertions, 16 deletions
diff --git a/languages/Language.php b/languages/Language.php
index dfbacfc0a7ca..eab09a1d1be9 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -3014,7 +3014,7 @@ class Language {
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgAllUnicodeFixes;
$s = UtfNormal\Validator::cleanUp( $s );
if ( $wgAllUnicodeFixes ) {
diff --git a/languages/classes/LanguageAr.php b/languages/classes/LanguageAr.php
index efdf5a27132b..f2ce1788e324 100644
--- a/languages/classes/LanguageAr.php
+++ b/languages/classes/LanguageAr.php
@@ -40,7 +40,7 @@ class LanguageAr extends Language {
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgFixArabicUnicode;
$s = parent::normalize( $s );
if ( $wgFixArabicUnicode ) {
diff --git a/languages/classes/LanguageMl.php b/languages/classes/LanguageMl.php
index cf45762ea88f..176c64c1350d 100644
--- a/languages/classes/LanguageMl.php
+++ b/languages/classes/LanguageMl.php
@@ -41,7 +41,7 @@ class LanguageMl extends Language {
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgFixMalayalamUnicode;
$s = parent::normalize( $s );
if ( $wgFixMalayalamUnicode ) {
diff --git a/tests/phpunit/languages/classes/LanguageArTest.php b/tests/phpunit/languages/classes/LanguageArTest.php
index f3f5a3f1f1bd..296ee6078820 100644
--- a/tests/phpunit/languages/classes/LanguageArTest.php
+++ b/tests/phpunit/languages/classes/LanguageArTest.php
@@ -1,32 +1,61 @@
<?php
-/**
- * Based on LanguagMlTest
- * @file
- */
/**
* @covers LanguageAr
*/
class LanguageArTest extends LanguageClassesTestCase {
+
/**
* @covers Language::formatNum
- * @todo split into a test and a dataprovider
+ * @dataProvider provideFormatNum
*/
- public function testFormatNum() {
- $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) );
- $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) );
+ public function testFormatNum( $num, $formatted ) {
+ $this->assertEquals( $formatted, $this->getLang()->formatNum( $num ) );
+ }
+
+ public static function provideFormatNum() {
+ return [
+ [ '1234567', '١٬٢٣٤٬٥٦٧' ],
+ [ -12.89, '-١٢٫٨٩' ],
+ ];
+ }
+
+ /**
+ * @covers LanguageAr::normalize
+ * @covers Language::normalize
+ * @dataProvider provideNormalize
+ */
+ public function testNormalize( $input, $expected ) {
+ if ( $input === $expected ) {
+ throw new Exception( 'Expected output must differ.' );
+ }
+
+ $this->setMwGlobals( 'wgFixArabicUnicode', true );
+ $this->assertSame( $expected, $this->getLang()->normalize( $input ), 'ar-normalised form' );
+
+ $this->setMwGlobals( 'wgFixArabicUnicode', false );
+ $this->assertSame( $input, $this->getLang()->normalize( $input ), 'regular normalised form' );
+ }
+
+ public static function provideNormalize() {
+ return [
+ [
+ 'ﷅ',
+ 'صمم',
+ ],
+ ];
}
/**
* Mostly to test the raw ascii feature.
- * @dataProvider providerSprintfDate
+ * @dataProvider provideSprintfDate
* @covers Language::sprintfDate
*/
public function testSprintfDate( $format, $date, $expected ) {
$this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
}
- public static function providerSprintfDate() {
+ public static function provideSprintfDate() {
return [
[
'xg "vs" g',
diff --git a/tests/phpunit/languages/classes/LanguageMlTest.php b/tests/phpunit/languages/classes/LanguageMlTest.php
index 673b5c775f69..59b7ba8d986d 100644
--- a/tests/phpunit/languages/classes/LanguageMlTest.php
+++ b/tests/phpunit/languages/classes/LanguageMlTest.php
@@ -11,15 +11,15 @@
class LanguageMlTest extends LanguageClassesTestCase {
/**
- * @dataProvider providerFormatNum
- * T31495
+ * @dataProvider provideFormatNum
* @covers Language::formatNum
*/
public function testFormatNum( $result, $value ) {
+ // For T31495
$this->assertEquals( $result, $this->getLang()->formatNum( $value ) );
}
- public static function providerFormatNum() {
+ public static function provideFormatNum() {
return [
[ '12,34,567', '1234567' ],
[ '12,345', '12345' ],
@@ -37,4 +37,30 @@ class LanguageMlTest extends LanguageClassesTestCase {
[ '', null ],
];
}
+
+ /**
+ * @covers LanguageMl::normalize
+ * @covers Language::normalize
+ * @dataProvider provideNormalize
+ */
+ public function testNormalize( $input, $expected ) {
+ if ( $input === $expected ) {
+ throw new Exception( 'Expected output must differ.' );
+ }
+
+ $this->setMwGlobals( 'wgFixMalayalamUnicode', true );
+ $this->assertSame( $expected, $this->getLang()->normalize( $input ), 'ml-normalised form' );
+
+ $this->setMwGlobals( 'wgFixMalayalamUnicode', false );
+ $this->assertSame( $input, $this->getLang()->normalize( $input ), 'regular normalised form' );
+ }
+
+ public static function provideNormalize() {
+ return [
+ [
+ 'ല്‍',
+ 'ൽ',
+ ],
+ ];
+ }
}
diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml
index e125b8a314e9..1917674f3efb 100644
--- a/tests/phpunit/suite.xml
+++ b/tests/phpunit/suite.xml
@@ -73,6 +73,8 @@
<directory suffix=".php">../../maintenance</directory>
<exclude>
<directory suffix=".php">../../languages/messages</directory>
+ <file>../../languages/data/normalize-ar.php</file>
+ <file>../../languages/data/normalize-ml.php</file>
</exclude>
</whitelist>
</filter>