Merge "CSSMin: Clean up the logic in getLocalFileReferences()"
[lhc/web/wiklou.git] / tests / phpunit / includes / MessageTest.php
index 71ebd6a..7c99352 100644 (file)
@@ -10,6 +10,33 @@ class MessageTest extends MediaWikiLangTestCase {
                ) );
        }
 
+       public function provideTestParams() {
+               return array(
+                       array( array() ),
+                       array( array( 'foo' ), 'foo' ),
+                       array( array( 'foo', 'bar' ), 'foo', 'bar' ),
+                       array( array( 'baz' ), array( 'baz' ) ),
+                       array( array( 'baz', 'foo' ), array( 'baz', 'foo' ) ),
+                       array( array( 'baz', 'foo' ), array( 'baz', 'foo' ), 'hhh' ),
+                       array( array( 'baz', 'foo' ), array( 'baz', 'foo' ), 'hhh', array( 'ahahahahha' ) ),
+                       array( array( 'baz', 'foo' ), array( 'baz', 'foo' ), array( 'ahahahahha' ) ),
+                       array( array( 'baz' ), array( 'baz' ), array( 'ahahahahha' ) ),
+               );
+       }
+
+       /**
+        * @covers Message::params
+        * @dataProvider provideTestParams
+        */
+       public function testParams( $expected ) {
+               $msg = new Message( 'imasomething' );
+
+               $returned = call_user_func_array( array( $msg, 'params' ),  array_slice( func_get_args(), 1 ) );
+
+               $this->assertSame( $msg, $returned );
+               $this->assertEquals( $expected, $msg->getParams() );
+       }
+
        /**
         * @covers Message::exists
         */
@@ -77,55 +104,84 @@ class MessageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * FIXME: This should not need database, but Language#formatExpiry does (bug 55912)
-        * @group Database
-        * @todo this should be split up into multiple test methods
         * @covers Message::numParams
-        * @covers Message::durationParams
-        * @covers Message::expiryParams
-        * @covers Message::timeperiodParams
-        * @covers Message::sizeParams
-        * @covers Message::bitrateParams
         */
-       public function testMessageParamTypes() {
+       public function testMessageNumParams() {
                $lang = Language::factory( 'en' );
-
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatNum( 123456.789 ),
                        $msg->inLanguage( $lang )->numParams( 123456.789 )->plain(),
                        'numParams is handled correctly'
                );
+       }
 
+       /**
+        * @covers Message::durationParams
+        */
+       public function testMessageDurationParams() {
+               $lang = Language::factory( 'en' );
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatDuration( 1234 ),
                        $msg->inLanguage( $lang )->durationParams( 1234 )->plain(),
                        'durationParams is handled correctly'
                );
+       }
 
+       /**
+        * FIXME: This should not need database, but Language#formatExpiry does (bug 55912)
+        * @group Database
+        * @covers Message::expiryParams
+        */
+       public function testMessageExpiryParams() {
+               $lang = Language::factory( 'en' );
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatExpiry( wfTimestampNow() ),
                        $msg->inLanguage( $lang )->expiryParams( wfTimestampNow() )->plain(),
                        'expiryParams is handled correctly'
                );
+       }
 
+       /**
+        * @covers Message::timeperiodParams
+        */
+       public function testMessageTimeperiodParams() {
+               $lang = Language::factory( 'en' );
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatTimePeriod( 1234 ),
                        $msg->inLanguage( $lang )->timeperiodParams( 1234 )->plain(),
                        'timeperiodParams is handled correctly'
                );
+       }
 
+       /**
+        * @covers Message::sizeParams
+        */
+       public function testMessageSizeParams() {
+               $lang = Language::factory( 'en' );
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatSize( 123456 ),
                        $msg->inLanguage( $lang )->sizeParams( 123456 )->plain(),
                        'sizeParams is handled correctly'
                );
+       }
 
+       /**
+        * @covers Message::bitrateParams
+        */
+       public function testMessageBitrateParams() {
+               $lang = Language::factory( 'en' );
                $msg = new RawMessage( '$1' );
+
                $this->assertEquals(
                        $lang->formatBitrate( 123456 ),
                        $msg->inLanguage( $lang )->bitrateParams( 123456 )->plain(),