diff options
author | Brad Jorsch <bjorsch@wikimedia.org> | 2018-09-27 11:04:24 -0400 |
---|---|---|
committer | David Barratt <dbarratt@wikimedia.org> | 2018-10-16 12:37:40 -0400 |
commit | 20d18cf3cb118cd09028e4d4f4939850e5023207 (patch) | |
tree | dbdbe4e07af4f8af6d78fdc1691e291aafefc011 /tests/phpunit/includes/api/ApiErrorFormatterTest.php | |
parent | 943c2f0bc1d65f759c8b56faf1e008991a41f2e8 (diff) | |
download | mediawikicore-20d18cf3cb118cd09028e4d4f4939850e5023207.tar.gz mediawikicore-20d18cf3cb118cd09028e4d4f4939850e5023207.zip |
API: Allow prop=info intestactions to return reasons
T194585 raises a use case for callers to be able to know why an action
is not allowed. We can make that possible easily enough. The default
remains to return only a boolean.
This also deprecates inprop=readable in favor of intestactions=read,
since they both just return `$title->userCan( 'read', $user )`.
(ApiQueryInfoTest added by David Barratt)
Bug: T194585
Change-Id: Ib880f0605880eac776d816ea04e0c7ab9cfbaab1
Co-Authored-By: David Barratt <dbarratt@wikimedia.org>
Diffstat (limited to 'tests/phpunit/includes/api/ApiErrorFormatterTest.php')
-rw-r--r-- | tests/phpunit/includes/api/ApiErrorFormatterTest.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/phpunit/includes/api/ApiErrorFormatterTest.php b/tests/phpunit/includes/api/ApiErrorFormatterTest.php index 144586e517d3..d11e3143ea01 100644 --- a/tests/phpunit/includes/api/ApiErrorFormatterTest.php +++ b/tests/phpunit/includes/api/ApiErrorFormatterTest.php @@ -14,6 +14,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase { $result = new ApiResult( 8388608 ); $formatter = new ApiErrorFormatter( $result, Language::factory( 'de' ), 'wikitext', false ); $this->assertSame( 'de', $formatter->getLanguage()->getCode() ); + $this->assertSame( 'wikitext', $formatter->getFormat() ); $formatter->addMessagesFromStatus( null, Status::newGood() ); $this->assertSame( @@ -33,6 +34,25 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase { /** * @covers ApiErrorFormatter + * @covers ApiErrorFormatter_BackCompat + */ + public function testNewWithFormat() { + $result = new ApiResult( 8388608 ); + $formatter = new ApiErrorFormatter( $result, Language::factory( 'de' ), 'wikitext', false ); + $formatter2 = $formatter->newWithFormat( 'html' ); + + $this->assertSame( $formatter->getLanguage(), $formatter2->getLanguage() ); + $this->assertSame( 'html', $formatter2->getFormat() ); + + $formatter3 = new ApiErrorFormatter_BackCompat( $result ); + $formatter4 = $formatter3->newWithFormat( 'html' ); + $this->assertNotInstanceOf( ApiErrorFormatter_BackCompat::class, $formatter4 ); + $this->assertSame( $formatter3->getLanguage(), $formatter4->getLanguage() ); + $this->assertSame( 'html', $formatter4->getFormat() ); + } + + /** + * @covers ApiErrorFormatter * @dataProvider provideErrorFormatter */ public function testErrorFormatter( $format, $lang, $useDB, @@ -351,6 +371,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase { $formatter = new ApiErrorFormatter_BackCompat( $result ); $this->assertSame( 'en', $formatter->getLanguage()->getCode() ); + $this->assertSame( 'bc', $formatter->getFormat() ); $this->assertSame( [], $formatter->arrayFromStatus( Status::newGood() ) ); |