From db67de7fad899de33d4c8e3b6ee8189f8570d826 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 20 Dec 2018 09:59:02 -0500 Subject: ApiDelete: Handle batched deletions properly When batched deletions via the job queue were added in Ie800fb5a, the way this was reported caused ApiDelete to report an error. Instead it should report success with appropriate signaling to the client. Bug: T212356 Change-Id: I1ef66277e988572c6720cf3e3cb36b18530746b4 --- .../phpunit/includes/api/ApiErrorFormatterTest.php | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/phpunit/includes/api/ApiErrorFormatterTest.php') diff --git a/tests/phpunit/includes/api/ApiErrorFormatterTest.php b/tests/phpunit/includes/api/ApiErrorFormatterTest.php index 312ef55e8fa4..d7628e0ccf75 100644 --- a/tests/phpunit/includes/api/ApiErrorFormatterTest.php +++ b/tests/phpunit/includes/api/ApiErrorFormatterTest.php @@ -634,6 +634,40 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase { ]; } + public function testAddMessagesFromStatus_filter() { + $result = new ApiResult( 8388608 ); + $formatter = new ApiErrorFormatter( $result, Language::factory( 'qqx' ), 'plaintext', false ); + + $status = Status::newGood(); + $status->warning( 'mainpage' ); + $status->warning( 'parentheses', 'foobar' ); + $status->warning( wfMessage( 'mainpage' ) ); + $status->error( 'mainpage' ); + $status->error( 'parentheses', 'foobaz' ); + $formatter->addMessagesFromStatus( 'status', $status, [ 'warning', 'error' ], [ 'mainpage' ] ); + $this->assertSame( [ + 'errors' => [ + [ + 'code' => 'parentheses', + 'text' => '(parentheses: foobaz)', + 'module' => 'status', + ApiResult::META_CONTENT => 'text', + ], + ApiResult::META_INDEXED_TAG_NAME => 'error', + ], + 'warnings' => [ + [ + 'code' => 'parentheses', + 'text' => '(parentheses: foobar)', + 'module' => 'status', + ApiResult::META_CONTENT => 'text', + ], + ApiResult::META_INDEXED_TAG_NAME => 'warning', + ], + ApiResult::META_TYPE => 'assoc', + ], $result->getResultData() ); + } + /** * @dataProvider provideIsValidApiCode * @covers ApiErrorFormatter::isValidApiCode -- cgit v1.2.3