Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTest.php
index dca1363..2f6fa39 100644 (file)
@@ -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' ] ],
+               ];
+       }
 }