X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Flanguages%2FLanguageTest.php;h=2f6fa39b36667209a67f1055c546bad913c598d5;hp=dca1363885bc6227fee19b77ab2a162afe4b47b6;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=c6ad2554f40f8ebbe9e38ac64ea933076f348729 diff --git a/tests/phpunit/languages/LanguageTest.php b/tests/phpunit/languages/LanguageTest.php index dca1363885..2f6fa39b36 100644 --- a/tests/phpunit/languages/LanguageTest.php +++ b/tests/phpunit/languages/LanguageTest.php @@ -135,6 +135,18 @@ class LanguageTest extends LanguageClassesTestCase { '48 hours 0 minutes', 'formatTimePeriod() rounding (=48h), avoidseconds' ], + [ + 259199.55, + 'avoidhours', + '3 d', + 'formatTimePeriod() rounding (>48h), avoidhours' + ], + [ + 259199.55, + [ 'avoid' => 'avoidhours', 'noabbrevs' => true ], + '3 days', + 'formatTimePeriod() rounding (>48h), avoidhours' + ], [ 259199.55, 'avoidminutes', @@ -1052,6 +1064,27 @@ class LanguageTest extends LanguageClassesTestCase { '平成24', 'nengo' ], + [ + 'xtY', + '20190430235959', + '平成31', + '平成31', + 'nengo - last day of heisei' + ], + [ + 'xtY', + '20190501000000', + '令和元', + '令和元', + 'nengo - first day of reiwa' + ], + [ + 'xtY', + '20200501000000', + '令和2', + '令和2', + 'nengo - second year of reiwa' + ], [ 'xrxkYY', '20120102090705', @@ -1909,4 +1942,27 @@ class LanguageTest extends LanguageClassesTestCase { $ar2 = new LanguageAr(); $this->assertTrue( $ar1->equals( $ar2 ), 'ar equals ar' ); } + + /** + * @dataProvider provideUcfirst + * @covers Language::ucfirst + */ + public function testUcfirst( $orig, $expected, $desc, $overrides = false ) { + $lang = new Language(); + if ( is_array( $overrides ) ) { + $this->setMwGlobals( [ 'wgOverrideUcfirstCharacters' => $overrides ] ); + } + $this->assertSame( $lang->ucfirst( $orig ), $expected, $desc ); + } + + public static function provideUcfirst() { + return [ + [ 'alice', 'Alice', 'simple ASCII string', false ], + [ 'århus', 'Århus', 'unicode string', false ], + //overrides do not affect ASCII characters + [ 'foo', 'Foo', 'ASCII is not overriden', [ 'f' => 'b' ] ], + // but they do affect non-ascii ones + [ 'èl', 'Ll' , 'Non-ASCII is overridden', [ 'è' => 'L' ] ], + ]; + } }