From: Bartosz DziewoƄski Date: Tue, 10 Oct 2017 20:36:31 +0000 (+0200) Subject: Add test cases for digit grouping (commafy) in Polish X-Git-Tag: 1.31.0-rc.0~1824^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=3f62813c51e7c2547616a8fa8d874c678aa20b9c;p=lhc%2Fweb%2Fwiklou.git Add test cases for digit grouping (commafy) in Polish According to the typographical convention, a thousands separator should not be inserted in numbers that are four digits long (between 1000 and 9999), unlike in English where it's usually acceptable. This logic is currently implemented in LanguagePl::commafy(). Bug: T177846 Change-Id: I6dbd8febcf59000067cdd7d3c11111f2f77f4e66 --- diff --git a/tests/phpunit/languages/classes/LanguagePlTest.php b/tests/phpunit/languages/classes/LanguagePlTest.php index a6d0f2e1cc..d7a0074397 100644 --- a/tests/phpunit/languages/classes/LanguagePlTest.php +++ b/tests/phpunit/languages/classes/LanguagePlTest.php @@ -74,4 +74,31 @@ class LanguagePlTest extends LanguageClassesTestCase { [ 'other', 201 ], ]; } + + /** + * @covers LanguagePl::commafy() + * @dataProvider provideCommafyData + */ + public function testCommafy( $number, $numbersWithCommas ) { + $this->assertEquals( + $numbersWithCommas, + $this->getLang()->commafy( $number ), + "commafy('$number')" + ); + } + + public static function provideCommafyData() { + // Note that commafy() always uses English separators (',' and '.') instead of + // Polish (' ' and ','). There is another function that converts them later. + return [ + [ 1000, '1000' ], + [ 10000, '10,000' ], + [ 1000.0001, '1000.0001' ], + [ 10000.0001, '10,000.0001' ], + [ -1000, '-1000' ], + [ -10000, '-10,000' ], + [ -1000.0001, '-1000.0001' ], + [ -10000.0001, '-10,000.0001' ], + ]; + } }