Fix magic getter for $status->ok
authorMark Holmquist <mtraceur@member.fsf.org>
Fri, 13 Feb 2015 17:29:58 +0000 (11:29 -0600)
committerGergő Tisza <tgr.huwiki@gmail.com>
Sat, 14 Feb 2015 00:05:41 +0000 (00:05 +0000)
__get called a non-existant function which caused errors
in file deletion.

Also adds tests for $status->ok and $status->errors

Change-Id: I8f5a21eb8d795e5e3f5a58f2384ad0dcbad749a2

includes/Status.php
tests/phpunit/includes/StatusTest.php

index 61a0047..cd10258 100644 (file)
@@ -437,7 +437,7 @@ class Status {
         */
        function __get( $name ) {
                if ( $name === 'ok' ) {
-                       return $this->sv->getOK();
+                       return $this->sv->isOK();
                } elseif ( $name === 'errors' ) {
                        return $this->sv->getErrors();
                }
index 44463cf..c013f4f 100644 (file)
@@ -56,6 +56,17 @@ class StatusTest extends MediaWikiLangTestCase {
                $this->assertEquals( $message, $status->getMessage()->getKey() );
        }
 
+       /**
+        *
+        */
+       public function testOkAndErrors() {
+               $status = Status::newGood( 'foo' );
+               $this->assertTrue( $status->ok );
+               $status = Status::newFatal( 'foo', 1, 2 );
+               $this->assertFalse( $status->ok );
+               $this->assertArrayEquals( array( array( 'type' => 'error', 'message' => 'foo', 'params' => array( 1, 2 ) ) ), $status->errors );
+       }
+
        /**
         * @dataProvider provideSetResult
         * @covers Status::setResult