Always return a string from Language::formatNum()
It says it returns a string, and so it should. Bug: T182277 Change-Id: Ic68c65c634c2557a1d07281623cd6c971b000323
This commit is contained in:
parent
847bc2b8d7
commit
313675320f
2 changed files with 28 additions and 1 deletions
|
|
@ -3268,7 +3268,7 @@ class Language {
|
|||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
return (string)$number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1629,6 +1629,33 @@ class LanguageTest extends LanguageClassesTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider testFormatNumProvider
|
||||
* @covers Language::formatNum
|
||||
*/
|
||||
public function testFormatNum(
|
||||
$translateNumerals, $langCode, $number, $nocommafy, $expected
|
||||
) {
|
||||
$this->setMwGlobals( [ 'wgTranslateNumerals' => $translateNumerals ] );
|
||||
$lang = Language::factory( $langCode );
|
||||
$formattedNum = $lang->formatNum( $number, $nocommafy );
|
||||
$this->assertType( 'string', $formattedNum );
|
||||
$this->assertEquals( $expected, $formattedNum );
|
||||
}
|
||||
|
||||
public function testFormatNumProvider() {
|
||||
return [
|
||||
[ true, 'en', 100, false, '100' ],
|
||||
[ true, 'en', 101, true, '101' ],
|
||||
[ false, 'en', 103, false, '103' ],
|
||||
[ false, 'en', 104, true, '104' ],
|
||||
[ true, 'en', '105', false, '105' ],
|
||||
[ true, 'en', '106', true, '106' ],
|
||||
[ false, 'en', '107', false, '107' ],
|
||||
[ false, 'en', '108', true, '108' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider parseFormattedNumberProvider
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue