diff --git a/tests/phpunit/includes/http/HttpTest.php b/tests/phpunit/includes/http/HttpTest.php index f727ccf6931..8d862b31e16 100644 --- a/tests/phpunit/includes/http/HttpTest.php +++ b/tests/phpunit/includes/http/HttpTest.php @@ -1,5 +1,7 @@ hideDeprecated( 'Http::getProxy' ); - $this->setMwGlobals( 'wgHTTPProxy', false ); + $this->overrideConfigValue( MainConfigNames::HTTPProxy, false ); $this->assertSame( '', Http::getProxy(), 'default setting' ); - $this->setMwGlobals( 'wgHTTPProxy', 'proxy.domain.tld' ); + $this->overrideConfigValue( MainConfigNames::HTTPProxy, 'proxy.domain.tld' ); $this->assertEquals( 'proxy.domain.tld', Http::getProxy() diff --git a/tests/phpunit/includes/import/ImportTest.php b/tests/phpunit/includes/import/ImportTest.php index b8f7078366a..562ee04a600 100644 --- a/tests/phpunit/includes/import/ImportTest.php +++ b/tests/phpunit/includes/import/ImportTest.php @@ -221,8 +221,9 @@ EOF */ public function testUnknownUserHandling( $assign, $create ) { $hookId = -99; - $this->setMwGlobals( 'wgHooks', [ - 'ImportHandleUnknownUser' => [ function ( $name ) use ( $assign, $create, &$hookId ) { + $this->setTemporaryHook( + 'ImportHandleUnknownUser', + function ( $name ) use ( $assign, $create, &$hookId ) { if ( !$assign ) { $this->fail( 'ImportHandleUnknownUser was called unexpectedly' ); } @@ -235,8 +236,8 @@ EOF return false; } return true; - } ] - ] ); + } + ); $user = $this->getTestUser()->getUser(); diff --git a/tests/phpunit/includes/interwiki/InterwikiTest.php b/tests/phpunit/includes/interwiki/InterwikiTest.php index cafeae84792..41bbb079483 100644 --- a/tests/phpunit/includes/interwiki/InterwikiTest.php +++ b/tests/phpunit/includes/interwiki/InterwikiTest.php @@ -1,5 +1,7 @@ setMwGlobals( 'wgInterwikiCache', $interwikiCache ); + $this->overrideConfigValue( MainConfigNames::InterwikiCache, $interwikiCache ); } public function testDatabaseStorage() { diff --git a/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php b/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php index 7395ad3a55a..12d5a91c68a 100644 --- a/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php +++ b/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php @@ -1,5 +1,6 @@ setMwGlobals( 'wgRCWatchCategoryMembership', true ); + $this->overrideConfigValue( MainConfigNames::RCWatchCategoryMembership, true ); $this->setContentLang( 'qqx' ); } diff --git a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php index 9016734a6d5..fc55171f924 100644 --- a/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php +++ b/tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php @@ -1,5 +1,7 @@ addWatch( $user, new TitleValue( 0, 'C' ) ); $watchedItemStore->addWatch( $user, new TitleValue( 1, 'C' ) ); - $this->setMwGlobals( 'wgUpdateRowsPerQuery', 2 ); + $this->overrideConfigValue( MainConfigNames::UpdateRowsPerQuery, 2 ); $jobQueueGroup = $this->getServiceContainer()->getJobQueueGroup(); $jobQueueGroup->push( @@ -66,7 +68,7 @@ class ClearUserWatchlistJobTest extends MediaWikiIntegrationTestCase { public function testRunWithWatchlistExpiry() { // Set up. - $this->setMwGlobals( 'wgWatchlistExpiry', true ); + $this->overrideConfigValue( MainConfigNames::WatchlistExpiry, true ); $user = $this->getUser(); $watchedItemStore = $this->getWatchedItemStore(); diff --git a/tests/phpunit/includes/language/LanguageFallbackIntegrationTest.php b/tests/phpunit/includes/language/LanguageFallbackIntegrationTest.php index b5f69b217f2..70781219b24 100644 --- a/tests/phpunit/includes/language/LanguageFallbackIntegrationTest.php +++ b/tests/phpunit/includes/language/LanguageFallbackIntegrationTest.php @@ -1,6 +1,7 @@ setMwGlobals( 'wgLanguageCode', $options['siteLangCode'] ); + $this->overrideConfigValue( MainConfigNames::LanguageCode, $options['siteLangCode'] ); } if ( isset( $options['fallbackMap'] ) ) { $this->setService( 'LocalisationCache', $this->getMockLocalisationCache( diff --git a/tests/phpunit/includes/libs/filebackend/fsfile/TempFSFileIntegrationTest.php b/tests/phpunit/includes/libs/filebackend/fsfile/TempFSFileIntegrationTest.php index 3e1503074d0..46d2cdf4072 100644 --- a/tests/phpunit/includes/libs/filebackend/fsfile/TempFSFileIntegrationTest.php +++ b/tests/phpunit/includes/libs/filebackend/fsfile/TempFSFileIntegrationTest.php @@ -1,5 +1,6 @@ setMwGlobals( 'wgTmpDirectory', '/hopefully invalid' ); + $this->overrideConfigValue( MainConfigNames::TmpDirectory, '/hopefully invalid' ); $factory = $this->getServiceContainer()->getTempFSFileFactory(); $this->assertSame( '/hopefully invalid', ( TestingAccessWrapper::newFromObject( $factory ) )->tmpDirectory ); diff --git a/tests/phpunit/includes/linkeddata/PageDataRequestHandlerTest.php b/tests/phpunit/includes/linkeddata/PageDataRequestHandlerTest.php index b734d6610a7..2b129078abd 100644 --- a/tests/phpunit/includes/linkeddata/PageDataRequestHandlerTest.php +++ b/tests/phpunit/includes/linkeddata/PageDataRequestHandlerTest.php @@ -1,5 +1,7 @@ interfaceTitle = Title::newFromText( __CLASS__ ); $this->obLevel = ob_get_level(); - $this->setMwGlobals( 'wgArticlePath', '/wiki/$1' ); + $this->overrideConfigValue( MainConfigNames::ArticlePath, '/wiki/$1' ); } protected function tearDown(): void { diff --git a/tests/phpunit/includes/linker/LinkRendererTest.php b/tests/phpunit/includes/linker/LinkRendererTest.php index fcadb8041d4..8f4beb37233 100644 --- a/tests/phpunit/includes/linker/LinkRendererTest.php +++ b/tests/phpunit/includes/linker/LinkRendererTest.php @@ -3,6 +3,7 @@ use MediaWiki\Config\ServiceOptions; use MediaWiki\Linker\LinkRenderer; use MediaWiki\Linker\LinkRendererFactory; +use MediaWiki\MainConfigNames; use MediaWiki\Page\PageReference; use MediaWiki\Page\PageReferenceValue; @@ -19,12 +20,12 @@ class LinkRendererTest extends MediaWikiLangTestCase { protected function setUp(): void { parent::setUp(); - $this->setMwGlobals( [ - 'wgArticlePath' => '/wiki/$1', - 'wgServer' => '//example.org', - 'wgCanonicalServer' => 'http://example.org', - 'wgScriptPath' => '/w', - 'wgScript' => '/w/index.php', + $this->overrideConfigValues( [ + MainConfigNames::ArticlePath => '/wiki/$1', + MainConfigNames::Server => '//example.org', + MainConfigNames::CanonicalServer => 'http://example.org', + MainConfigNames::ScriptPath => '/w', + MainConfigNames::Script => '/w/index.php', ] ); $this->factory = $this->getServiceContainer()->getLinkRendererFactory(); } diff --git a/tests/phpunit/includes/logging/BlockLogFormatterTest.php b/tests/phpunit/includes/logging/BlockLogFormatterTest.php index b57d482eb74..6e847ef0806 100644 --- a/tests/phpunit/includes/logging/BlockLogFormatterTest.php +++ b/tests/phpunit/includes/logging/BlockLogFormatterTest.php @@ -357,8 +357,7 @@ class BlockLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressBlockLogDatabaseRows */ public function testSuppressBlockLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', + $this->setGroupPermissions( [ 'oversight' => [ 'viewsuppressed' => true, @@ -499,8 +498,7 @@ class BlockLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressReblockLogDatabaseRows */ public function testSuppressReblockLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', + $this->setGroupPermissions( [ 'oversight' => [ 'viewsuppressed' => true, diff --git a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php index e6956a03b55..a9c718ba45f 100644 --- a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php +++ b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php @@ -477,8 +477,7 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressRevisionLogDatabaseRows */ public function testSuppressRevisionLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', + $this->setGroupPermissions( [ 'oversight' => [ 'viewsuppressed' => true, @@ -719,8 +718,7 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressEventLogDatabaseRows */ public function testSuppressEventLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', + $this->setGroupPermissions( [ 'oversight' => [ 'viewsuppressed' => true, @@ -891,8 +889,7 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressDeleteLogDatabaseRows */ public function testSuppressDeleteLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', + $this->setGroupPermissions( [ 'oversight' => [ 'viewsuppressed' => true, diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php b/tests/phpunit/includes/logging/LogFormatterTest.php index 0911d860e39..d24f9435f29 100644 --- a/tests/phpunit/includes/logging/LogFormatterTest.php +++ b/tests/phpunit/includes/logging/LogFormatterTest.php @@ -1,5 +1,6 @@ setMwGlobals( [ - 'wgLogTypes' => [ 'phpunit' ], - 'wgLogActionsHandlers' => [ 'phpunit/test' => LogFormatter::class, + $this->overrideConfigValues( [ + MainConfigNames::LogTypes => [ 'phpunit' ], + MainConfigNames::LogActionsHandlers => [ 'phpunit/test' => LogFormatter::class, 'phpunit/param' => LogFormatter::class ], ] ); diff --git a/tests/phpunit/includes/mail/EmailNotificationTest.php b/tests/phpunit/includes/mail/EmailNotificationTest.php index 50e2f5af735..a13d39fee58 100644 --- a/tests/phpunit/includes/mail/EmailNotificationTest.php +++ b/tests/phpunit/includes/mail/EmailNotificationTest.php @@ -1,5 +1,7 @@ emailNotification = new EmailNotification(); - $this->setMwGlobals( [ - 'wgWatchlistExpiry' => true, - ] ); + $this->overrideConfigValue( MainConfigNames::WatchlistExpiry, true ); } /** diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php index f66196e4251..a3752432901 100644 --- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php +++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php @@ -1,5 +1,7 @@ setMwGlobals( 'wgShowEXIF', false ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, false ); $this->filePath = __DIR__ . '/../../data/media/'; } @@ -26,7 +28,7 @@ class BitmapMetadataHandlerTest extends MediaWikiIntegrationTestCase { $this->checkPHPExtension( 'exif' ); $this->checkPHPExtension( 'xml' ); - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); $meta = BitmapMetadataHandler::Jpeg( $this->filePath . '/Xmp-exif-multilingual_test.jpg' ); diff --git a/tests/phpunit/includes/media/BitmapScalingTest.php b/tests/phpunit/includes/media/BitmapScalingTest.php index ee842a6d217..ed09ea236b1 100644 --- a/tests/phpunit/includes/media/BitmapScalingTest.php +++ b/tests/phpunit/includes/media/BitmapScalingTest.php @@ -1,5 +1,7 @@ setMwGlobals( [ - 'wgMaxImageArea' => 1.25e7, // 3500x3500 - 'wgCustomConvertCommand' => 'dummy', // Set so that we don't get client side rendering + $this->overrideConfigValues( [ + MainConfigNames::MaxImageArea => 1.25e7, // 3500x3500 + MainConfigNames::CustomConvertCommand => 'dummy', // Set so that we don't get client side rendering ] ); } diff --git a/tests/phpunit/includes/media/ExifBitmapTest.php b/tests/phpunit/includes/media/ExifBitmapTest.php index 88536ea70db..3d8a62b5aa3 100644 --- a/tests/phpunit/includes/media/ExifBitmapTest.php +++ b/tests/phpunit/includes/media/ExifBitmapTest.php @@ -1,5 +1,7 @@ checkPHPExtension( 'exif' ); - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); $this->handler = new ExifBitmapHandler; } diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index 217f8028f9e..352737a5cfd 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -1,4 +1,7 @@ handler = new BitmapHandler(); - $this->setMwGlobals( [ - 'wgShowEXIF' => true, - 'wgEnableAutoRotation' => true, + $this->overrideConfigValues( [ + MainConfigNames::ShowEXIF => true, + MainConfigNames::EnableAutoRotation => true, ] ); } @@ -52,9 +55,11 @@ class ExifRotationTest extends MediaWikiMediaTestCase { * @dataProvider provideFiles */ public function testMetadataAutoRotate( $name, $type, $info ) { - $this->setMwGlobals( 'wgEnableAutoRotation', null ); - $this->setMwGlobals( 'wgUseImageMagick', true ); - $this->setMwGlobals( 'wgUseImageResize', true ); + $this->overrideConfigValues( [ + MainConfigNames::EnableAutoRotation => null, + MainConfigNames::UseImageMagick => true, + MainConfigNames::UseImageResize => true, + ] ); $file = $this->dataFile( $name, $type ); $this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" ); @@ -146,7 +151,7 @@ class ExifRotationTest extends MediaWikiMediaTestCase { * @dataProvider provideFilesNoAutoRotate */ public function testMetadataNoAutoRotate( $name, $type, $info ) { - $this->setMwGlobals( 'wgEnableAutoRotation', false ); + $this->overrideConfigValue( MainConfigNames::EnableAutoRotation, false ); $file = $this->dataFile( $name, $type ); $this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" ); @@ -158,8 +163,10 @@ class ExifRotationTest extends MediaWikiMediaTestCase { * @dataProvider provideFilesNoAutoRotate */ public function testMetadataAutoRotateUnsupported( $name, $type, $info ) { - $this->setMwGlobals( 'wgEnableAutoRotation', null ); - $this->setMwGlobals( 'wgUseImageResize', false ); + $this->overrideConfigValues( [ + MainConfigNames::EnableAutoRotation => null, + MainConfigNames::UseImageResize => false, + ] ); $file = $this->dataFile( $name, $type ); $this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" ); @@ -170,7 +177,7 @@ class ExifRotationTest extends MediaWikiMediaTestCase { * @dataProvider provideFilesNoAutoRotate */ public function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) { - $this->setMwGlobals( 'wgEnableAutoRotation', false ); + $this->overrideConfigValue( MainConfigNames::EnableAutoRotation, false ); foreach ( $thumbs as $size => $out ) { if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) { diff --git a/tests/phpunit/includes/media/ExifTest.php b/tests/phpunit/includes/media/ExifTest.php index 827783a2dc2..8fa6db2ce24 100644 --- a/tests/phpunit/includes/media/ExifTest.php +++ b/tests/phpunit/includes/media/ExifTest.php @@ -1,5 +1,7 @@ mediaPath = __DIR__ . '/../../data/media/'; - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); } public function testGPSExtraction() { diff --git a/tests/phpunit/includes/media/JpegPixelFormatTest.php b/tests/phpunit/includes/media/JpegPixelFormatTest.php index 731663426b1..81133797dac 100644 --- a/tests/phpunit/includes/media/JpegPixelFormatTest.php +++ b/tests/phpunit/includes/media/JpegPixelFormatTest.php @@ -1,5 +1,6 @@ setMwGlobals( 'wgJpegPixelFormat', $pixelFormat ); + $this->overrideConfigValue( MainConfigNames::JpegPixelFormat, $pixelFormat ); $file = $this->dataFile( $sourceFile, 'image/jpeg' ); diff --git a/tests/phpunit/includes/media/JpegTest.php b/tests/phpunit/includes/media/JpegTest.php index 851e30232df..4ac2837d5e0 100644 --- a/tests/phpunit/includes/media/JpegTest.php +++ b/tests/phpunit/includes/media/JpegTest.php @@ -1,5 +1,7 @@ checkPHPExtension( 'exif' ); - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); $this->handler = new JpegHandler; } @@ -75,7 +77,7 @@ class JpegTest extends MediaWikiMediaTestCase { $this->markTestSkipped( "Exiftool not installed, cannot test ICC profile swapping" ); } - $this->setMwGlobals( 'wgUseTinyRGBForJPGThumbnails', true ); + $this->overrideConfigValue( MainConfigNames::UseTinyRGBForJPGThumbnails, true ); $sourceFilepath = $this->filePath . $sourceFilename; $controlFilepath = $this->filePath . $controlFilename; diff --git a/tests/phpunit/includes/media/SvgHandlerTest.php b/tests/phpunit/includes/media/SvgHandlerTest.php index 8a2c0a29e3b..797248a2865 100644 --- a/tests/phpunit/includes/media/SvgHandlerTest.php +++ b/tests/phpunit/includes/media/SvgHandlerTest.php @@ -1,5 +1,6 @@ filePath = __DIR__ . '/../../data/media/'; - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); $file = $this->dataFile( $filename, 'image/svg+xml' ); $handler = new SvgHandler(); @@ -208,7 +209,7 @@ class SvgHandlerTest extends MediaWikiMediaTestCase { array $params, array $paramsExpected = null ) { - $this->setMwGlobals( 'wgSVGMaxSize', 1000 ); + $this->overrideConfigValue( MainConfigNames::SVGMaxSize, 1000 ); /** @var SvgHandler $handler */ $handler = TestingAccessWrapper::newFromObject( new SvgHandler() ); @@ -293,7 +294,7 @@ class SvgHandlerTest extends MediaWikiMediaTestCase { * @param bool $expected */ public function testIsEnabled( $converter, $expected ) { - $this->setMwGlobals( 'wgSVGConverter', $converter ); + $this->overrideConfigValue( MainConfigNames::SVGConverter, $converter ); $handler = new SvgHandler(); self::assertEquals( $expected, $handler->isEnabled() ); diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php index 3042ef8bdb4..d5bd6a2be37 100644 --- a/tests/phpunit/includes/media/TiffTest.php +++ b/tests/phpunit/includes/media/TiffTest.php @@ -1,5 +1,7 @@ checkPHPExtension( 'exif' ); - $this->setMwGlobals( 'wgShowEXIF', true ); + $this->overrideConfigValue( MainConfigNames::ShowEXIF, true ); $this->filePath = __DIR__ . '/../../data/media/'; $this->handler = new TiffHandler; diff --git a/tests/phpunit/includes/objectcache/ObjectCacheTest.php b/tests/phpunit/includes/objectcache/ObjectCacheTest.php index a1cee9f89b4..38de1fa7310 100644 --- a/tests/phpunit/includes/objectcache/ObjectCacheTest.php +++ b/tests/phpunit/includes/objectcache/ObjectCacheTest.php @@ -1,5 +1,7 @@ setCacheConfig(); - $this->setMwGlobals( [ - 'wgMainCacheType' => CACHE_NONE, - 'wgMessageCacheType' => CACHE_NONE, - 'wgParserCacheType' => CACHE_NONE, + $this->setMainCache( CACHE_NONE ); + $this->overrideConfigValues( [ + MainConfigNames::MessageCacheType => CACHE_NONE, + MainConfigNames::ParserCacheType => CACHE_NONE, ] ); } @@ -24,7 +26,7 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { CACHE_ACCEL => [ 'class' => HashBagOStuff::class ], 'hash' => [ 'class' => HashBagOStuff::class ], ]; - $this->setMwGlobals( 'wgObjectCaches', $arr + $defaults ); + $this->overrideConfigValue( MainConfigNames::ObjectCaches, $arr + $defaults ); } /** @covers ObjectCache::newAnything */ @@ -38,9 +40,7 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { /** @covers ObjectCache::newAnything */ public function testNewAnythingHash() { - $this->setMwGlobals( [ - 'wgMainCacheType' => 'hash' - ] ); + $this->setMainCache( CACHE_HASH ); $this->assertInstanceOf( HashBagOStuff::class, @@ -51,9 +51,7 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { /** @covers ObjectCache::newAnything */ public function testNewAnythingAccel() { - $this->setMwGlobals( [ - 'wgMainCacheType' => CACHE_ACCEL - ] ); + $this->setMainCache( CACHE_ACCEL ); $this->assertInstanceOf( HashBagOStuff::class, @@ -64,9 +62,7 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { /** @covers ObjectCache::newAnything */ public function testNewAnythingNoAccel() { - $this->setMwGlobals( [ - 'wgMainCacheType' => CACHE_ACCEL - ] ); + $this->setMainCache( CACHE_ACCEL ); $this->setCacheConfig( [ // Mock APC not being installed (T160519, T147161) @@ -82,9 +78,7 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { /** @covers ObjectCache::newAnything */ public function testNewAnythingNoAccelNoDb() { - $this->setMwGlobals( [ - 'wgMainCacheType' => CACHE_ACCEL - ] ); + $this->setMainCache( CACHE_ACCEL ); $this->setCacheConfig( [ // Mock APC not being installed (T160519, T147161)