Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / LanguagePlTest.php
index d180037..d7a0074 100644 (file)
@@ -12,7 +12,7 @@ class LanguagePlTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many' );
+               $forms = [ 'one', 'few', 'many' ];
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -25,24 +25,24 @@ class LanguagePlTest extends LanguageClassesTestCase {
        }
 
        public static function providePlural() {
-               return array(
-                       array( 'many', 0 ),
-                       array( 'one', 1 ),
-                       array( 'few', 2 ),
-                       array( 'few', 3 ),
-                       array( 'few', 4 ),
-                       array( 'many', 5 ),
-                       array( 'many', 9 ),
-                       array( 'many', 10 ),
-                       array( 'many', 11 ),
-                       array( 'many', 21 ),
-                       array( 'few', 22 ),
-                       array( 'few', 23 ),
-                       array( 'few', 24 ),
-                       array( 'many', 25 ),
-                       array( 'many', 200 ),
-                       array( 'many', 201 ),
-               );
+               return [
+                       [ 'many', 0 ],
+                       [ 'one', 1 ],
+                       [ 'few', 2 ],
+                       [ 'few', 3 ],
+                       [ 'few', 4 ],
+                       [ 'many', 5 ],
+                       [ 'many', 9 ],
+                       [ 'many', 10 ],
+                       [ 'many', 11 ],
+                       [ 'many', 21 ],
+                       [ 'few', 22 ],
+                       [ 'few', 23 ],
+                       [ 'few', 24 ],
+                       [ 'many', 25 ],
+                       [ 'many', 200 ],
+                       [ 'many', 201 ],
+               ];
        }
 
        /**
@@ -50,28 +50,55 @@ class LanguagePlTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPluralTwoForms( $result, $value ) {
-               $forms = array( 'one', 'other' );
+               $forms = [ 'one', 'other' ];
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
        public static function providePluralTwoForms() {
-               return array(
-                       array( 'other', 0 ),
-                       array( 'one', 1 ),
-                       array( 'other', 2 ),
-                       array( 'other', 3 ),
-                       array( 'other', 4 ),
-                       array( 'other', 5 ),
-                       array( 'other', 9 ),
-                       array( 'other', 10 ),
-                       array( 'other', 11 ),
-                       array( 'other', 21 ),
-                       array( 'other', 22 ),
-                       array( 'other', 23 ),
-                       array( 'other', 24 ),
-                       array( 'other', 25 ),
-                       array( 'other', 200 ),
-                       array( 'other', 201 ),
+               return [
+                       [ 'other', 0 ],
+                       [ 'one', 1 ],
+                       [ 'other', 2 ],
+                       [ 'other', 3 ],
+                       [ 'other', 4 ],
+                       [ 'other', 5 ],
+                       [ 'other', 9 ],
+                       [ 'other', 10 ],
+                       [ 'other', 11 ],
+                       [ 'other', 21 ],
+                       [ 'other', 22 ],
+                       [ 'other', 23 ],
+                       [ 'other', 24 ],
+                       [ 'other', 25 ],
+                       [ 'other', 200 ],
+                       [ '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' ],
+               ];
+       }
 }