Use overrideConfigValues/overrideConfigValue instead of setMwGlobals

Also use MainConfigNames.

Change-Id: I35c7099a63f8665ddf433116732a93ede8711e35
This commit is contained in:
Fomafix 2024-07-30 15:03:40 +00:00
parent de16ec7509
commit 805a1e8248
3 changed files with 10 additions and 8 deletions

View file

@ -9,6 +9,7 @@ use MediaWiki\Extension\AbuseFilter\FilterRunnerFactory;
use MediaWiki\Extension\AbuseFilter\Hooks\Handlers\FilteredActionsHandler;
use MediaWiki\Extension\AbuseFilter\Parser\AFPData;
use MediaWiki\Json\FormatJson;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Status\Status;
use MediaWiki\Storage\PageEditStash;
@ -318,10 +319,10 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
ConvertibleTimestamp::setFakeTime( time() );
// Make sure that the config we're using is the one we're expecting
$this->setMwGlobals( [
$this->overrideConfigValues( [
// Exclude noisy creation log
'wgPageCreationLog' => false,
'wgAbuseFilterActions' => [
MainConfigNames::PageCreationLog => false,
'AbuseFilterActions' => [
'throttle' => true,
'warn' => true,
'disallow' => true,
@ -1474,9 +1475,9 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
* @covers \MediaWiki\Extension\AbuseFilter\AbuseLogger
*/
public function testGlobalFilters( $createIds, $actionParams, $consequences ) {
$this->setMwGlobals( [
'wgAbuseFilterCentralDB' => WikiMap::getCurrentWikiId(),
'wgAbuseFilterIsCentral' => false,
$this->overrideConfigValues( [
'AbuseFilterCentralDB' => WikiMap::getCurrentWikiId(),
'AbuseFilterIsCentral' => false,
] );
$this->createFilters( $createIds );

View file

@ -1,5 +1,6 @@
<?php
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Request\FauxRequest;
use MediaWiki\Tests\Api\RandomImageGenerator;
@ -43,7 +44,7 @@ trait AbuseFilterUploadTestTrait {
protected function doUpload( User $user, string $fileName, string $pageText, string $summary ): array {
global $wgFileExtensions;
$this->setMwGlobals( [ 'wgFileExtensions' => [ ...$wgFileExtensions, 'svg' ] ] );
$this->overrideConfigValue( MainConfigNames::FileExtensions, [ ...$wgFileExtensions, 'svg' ] );
$imgGen = new RandomImageGenerator();
// Use SVG, since the ImageGenerator doesn't need anything special to create it
$format = 'svg';

View file

@ -34,7 +34,7 @@ class FilteredActionsHandlerTest extends \MediaWikiIntegrationTestCase {
* @covers \MediaWiki\Extension\AbuseFilter\BlockedDomainFilter
*/
public function testOnEditFilterMergedContent( $urlsAdded, $expected ) {
$this->setMwGlobals( 'wgAbuseFilterEnableBlockedExternalDomain', true );
$this->overrideConfigValue( 'AbuseFilterEnableBlockedExternalDomain', true );
$filteredActionsHandler = $this->getFilteredActionsHandler( $urlsAdded );
$context = RequestContext::getMain();