From 7a8440210874d265a73468607647eb9910ba80a5 Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Fri, 13 Feb 2015 11:29:58 -0600 Subject: [PATCH] Fix magic getter for $status->ok __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 | 2 +- tests/phpunit/includes/StatusTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/Status.php b/includes/Status.php index 61a00470a5..cd10258d58 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -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(); } diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index 44463cf6d7..c013f4fcdd 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -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 -- 2.20.1