Add test to complete coverage of getStatusArray
authoraddshore <addshorewiki@gmail.com>
Sat, 22 Feb 2014 11:00:18 +0000 (12:00 +0100)
committeraddshore <addshorewiki@gmail.com>
Sat, 22 Feb 2014 11:00:18 +0000 (12:00 +0100)
Change-Id: Ia2f9b5a723d85d19ee7a24fcf9b132d0289705f0

tests/phpunit/includes/StatusTest.php

index 9cafe2c..209b54c 100644 (file)
@@ -531,4 +531,29 @@ class StatusTest extends MediaWikiLangTestCase {
                $this->assertEquals( false, $status->cleanCallback );
        }
 
+       /**
+        * @dataProvider provideNonObjectMessages
+        * @covers Status::getStatusArray
+        */
+       public function testGetStatusArrayWithNonObjectMessages( $nonObjMsg ) {
+               $status = new Status();
+               if( !array_key_exists( 1, $nonObjMsg ) ) {
+                       $status->warning( $nonObjMsg[0] );
+               } else {
+                       $status->warning( $nonObjMsg[0], $nonObjMsg[1] );
+               }
+
+               $array = $status->getWarningsArray(); // We use getWarningsArray to access getStatusArray
+
+               $this->assertEquals( 1, count( $array ) );
+               $this->assertEquals( $nonObjMsg, $array[0] );
+       }
+
+       public static function provideNonObjectMessages() {
+               return array(
+                       array( array( 'ImaString', array( 'param1' => 'value1' ) ) ),
+                       array( array( 'ImaString' ) ),
+               );
+       }
+
 }