Add test for Status->merge with overrideValue true
authoraddshore <addshorewiki@gmail.com>
Sat, 25 Jan 2014 15:08:49 +0000 (16:08 +0100)
committeraddshore <addshorewiki@gmail.com>
Sat, 25 Jan 2014 15:08:49 +0000 (16:08 +0100)
Change-Id: I049c67e80277f8dbbbadae6e7a8f30d66066e7bf

tests/phpunit/includes/StatusTest.php

index a3d68b6..aa5367e 100644 (file)
@@ -200,7 +200,6 @@ class StatusTest extends MediaWikiLangTestCase {
 
        /**
         * @covers Status::merge
-        * @todo test merge with $overwriteValue true
         */
        public function testMerge() {
                $status1 = new Status();
@@ -214,6 +213,23 @@ class StatusTest extends MediaWikiLangTestCase {
                $this->assertEquals( 2, count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) );
        }
 
+       /**
+        * @covers Status::merge
+        */
+       public function testMergeWithOverwriteValue() {
+               $status1 = new Status();
+               $status2 = new Status();
+               $message1 = $this->getMockMessage( 'warn1' );
+               $message2 = $this->getMockMessage( 'error2' );
+               $status1->warning( $message1 );
+               $status2->error( $message2 );
+               $status2->value = 'FooValue';
+
+               $status1->merge( $status2, true );
+               $this->assertEquals( 2, count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) );
+               $this->assertEquals( 'FooValue', $status1->getValue() );
+       }
+
        /**
         * @covers Status::hasMessage
         */