aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/ApiErrorFormatterTest.php
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2018-12-20 09:59:02 -0500
committerBrad Jorsch <bjorsch@wikimedia.org>2018-12-20 10:03:26 -0500
commitdb67de7fad899de33d4c8e3b6ee8189f8570d826 (patch)
tree9de29f4bab6d3cf95ed3ebdf9e08b5f3463429ee /tests/phpunit/includes/api/ApiErrorFormatterTest.php
parentf2d4db9d03a984d998db9044e63e548597511eb6 (diff)
downloadmediawikicore-db67de7fad899de33d4c8e3b6ee8189f8570d826.tar.gz
mediawikicore-db67de7fad899de33d4c8e3b6ee8189f8570d826.zip
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
Diffstat (limited to 'tests/phpunit/includes/api/ApiErrorFormatterTest.php')
-rw-r--r--tests/phpunit/includes/api/ApiErrorFormatterTest.php34
1 files changed, 34 insertions, 0 deletions
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