Why:
* Since 1941f28f60, the
recentchangesfeed API (ApiFeedRecentChanges) has treated
temporary accounts as being anon users for the purposes of the
'hideanons' parameter.
* However, the help text does not describe that temporary accounts
are treated in this way and as such the help text needs to be
modified depending on whether temporary accounts are enabled.
What:
* Add 'apihelp-feedrecentchanges-param-hideanons-temp' as a i18n
message which duplicates the existing 'apihelp-feedrecentchanges
-param-hideanons' but includes temporary accounts.
* Update ApiFeedRecentChanges::getAllowedParams to use the new
message if TempUserConfig::isEnabled returns true.
* Add the TempUserConfig as a injected dependency for
ApiFeedRecentChanges.
* Add an integration test to verify that the correct help message
is used for the 'hideanons' parameter in ApiFeedRecentChanges.
Bug: T358249
Change-Id: I516c1a563a81777217cda998efaeda7967dd224d
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Api;
|
|
|
|
use ApiBase;
|
|
use ApiFeedRecentChanges;
|
|
use ApiMain;
|
|
use MediaWiki\Context\RequestContext;
|
|
use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @group API
|
|
* @covers \ApiFeedRecentChanges
|
|
*/
|
|
class ApiFeedRecentChangesTest extends MediaWikiIntegrationTestCase {
|
|
|
|
use TempUserTestTrait;
|
|
|
|
private function commonTestGetAllowedParamsForHideAnons( $expectedMessageKey ) {
|
|
$ctx = new RequestContext();
|
|
$apiMain = new ApiMain( $ctx );
|
|
$api = new ApiFeedRecentChanges(
|
|
$apiMain,
|
|
'feedrecentchanges',
|
|
$this->getServiceContainer()->getSpecialPageFactory(),
|
|
$this->getServiceContainer()->getTempUserConfig()
|
|
);
|
|
$params = $api->getAllowedParams();
|
|
$this->assertArrayHasKey( 'hideanons', $params );
|
|
$this->assertSame(
|
|
$expectedMessageKey,
|
|
$params['hideanons'][ApiBase::PARAM_HELP_MSG]
|
|
);
|
|
}
|
|
|
|
public function testGetAllowedParamsWhenTemporaryAccountsAreEnabled() {
|
|
$this->enableAutoCreateTempUser();
|
|
$this->commonTestGetAllowedParamsForHideAnons(
|
|
'apihelp-feedrecentchanges-param-hideanons-temp'
|
|
);
|
|
}
|
|
|
|
public function testGetAllowedParamsWhenTemporaryAccountsAreNotEnabled() {
|
|
$this->disableAutoCreateTempUser();
|
|
$this->commonTestGetAllowedParamsForHideAnons(
|
|
'apihelp-feedrecentchanges-param-hideanons'
|
|
);
|
|
}
|
|
}
|