Debian Codegraph @

tests/phpunit/includes/api/ApiFeedRecentChangesTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Api;
4
5 use MediaWiki\Api\ApiBase;
6 use MediaWiki\Api\ApiFeedRecentChanges;
7 use MediaWiki\Api\ApiMain;
8 use MediaWiki\Context\RequestContext;
9 use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
10 use MediaWikiIntegrationTestCase;
11
12 /**
13 * @group API
14 * @covers \MediaWiki\Api\ApiFeedRecentChanges
15 */
16 class ApiFeedRecentChangesTest extends MediaWikiIntegrationTestCase {
17
18 use TempUserTestTrait;
19
20 private function commonTestGetAllowedParamsForHideAnons( $expectedMessageKey ) {
21 $ctx = new RequestContext();
22 $apiMain = new ApiMain( $ctx );
23 $api = new ApiFeedRecentChanges(
24 $apiMain,
25 'feedrecentchanges',
26 $this->getServiceContainer()->getSpecialPageFactory(),
27 $this->getServiceContainer()->getTempUserConfig()
28 );
29 $params = $api->getAllowedParams();
30 $this->assertArrayHasKey( 'hideanons', $params );
31 $this->assertSame(
32 $expectedMessageKey,
33 $params['hideanons'][ApiBase::PARAM_HELP_MSG]
34 );
35 }
36
37 public function testGetAllowedParamsWhenTemporaryAccountsAreEnabled() {
38 $this->enableAutoCreateTempUser();
39 $this->commonTestGetAllowedParamsForHideAnons(
40 'apihelp-feedrecentchanges-param-hideanons-temp'
41 );
42 }
43
44 public function testGetAllowedParamsWhenTemporaryAccountsAreNotEnabled() {
45 $this->disableAutoCreateTempUser();
46 $this->commonTestGetAllowedParamsForHideAnons(
47 'apihelp-feedrecentchanges-param-hideanons'
48 );
49 }
50 }