* Exclude the data files from PHPUnit coverage.
* Add tests covering the normalize() implementations.
* Fix a small todo about using data providers.
* Set explicit visibility.
Change-Id: Ib104cc3215a36901cff853ad5969d92a6e0cf6a0
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgAllUnicodeFixes;
$s = UtfNormal\Validator::cleanUp( $s );
if ( $wgAllUnicodeFixes ) {
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgFixArabicUnicode;
$s = parent::normalize( $s );
if ( $wgFixArabicUnicode ) {
*
* @return string
*/
- function normalize( $s ) {
+ public function normalize( $s ) {
global $wgFixMalayalamUnicode;
$s = parent::normalize( $s );
if ( $wgFixMalayalamUnicode ) {
<?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',
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' ],
[ '', 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 [
+ [
+ 'ല്',
+ 'ൽ',
+ ],
+ ];
+ }
}
<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>