aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit
diff options
context:
space:
mode:
authorDerick Alangi <alangiderick@gmail.com>2022-07-20 13:42:41 +0100
committerDerick Alangi <alangiderick@gmail.com>2022-07-23 05:53:49 +0100
commit6e5f2d0822a1fce64bb16c1bce51ea2d727263bb (patch)
tree9f5f5707fda36bf1fa0a2e35c9a0dcd08cfd4931 /tests/phpunit
parent8cb010b2211fa97e00cce2d06bc41488915742f1 (diff)
downloadmediawikicore-6e5f2d0822a1fce64bb16c1bce51ea2d727263bb.tar.gz
mediawikicore-6e5f2d0822a1fce64bb16c1bce51ea2d727263bb.zip
tests: Migrate `setMwGlobals()` to `overrideConfigValue(s)()`
Directories covered are: - tests/phpunit/includes/cache/ - tests/phpunit/includes/changes/ - tests/phpunit/includes/changetags/ - tests/phpunit/includes/config/ - tests/phpunit/includes/content/ - tests/phpunit/includes/debug/ - tests/phpunit/includes/deferred/ - tests/phpunit/includes/diff/ Change-Id: I3a1f586867db7d57b177e13a03a4593f7eed09f4
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/includes/cache/MessageCacheTest.php13
-rw-r--r--tests/phpunit/includes/changes/OldChangesListTest.php6
-rw-r--r--tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php5
-rw-r--r--tests/phpunit/includes/changes/RecentChangeTest.php7
-rw-r--r--tests/phpunit/includes/changetags/ChangeTagsTest.php6
-rw-r--r--tests/phpunit/includes/content/ContentHandlerTest.php25
-rw-r--r--tests/phpunit/includes/content/CssContentHandlerTest.php8
-rw-r--r--tests/phpunit/includes/content/CssContentTest.php17
-rw-r--r--tests/phpunit/includes/content/JavaScriptContentHandlerTest.php8
-rw-r--r--tests/phpunit/includes/content/JavaScriptContentTest.php22
-rw-r--r--tests/phpunit/includes/content/RegistrationContentHandlerFactoryToMediaWikiServicesTest.php11
-rw-r--r--tests/phpunit/includes/content/TextContentTest.php12
-rw-r--r--tests/phpunit/includes/content/WikitextContentHandlerTest.php3
-rw-r--r--tests/phpunit/includes/debug/DeprecationHelperTest.php3
-rw-r--r--tests/phpunit/includes/debug/logger/LegacyLoggerTest.php3
-rw-r--r--tests/phpunit/includes/deferred/LinksUpdateTest.php15
-rw-r--r--tests/phpunit/includes/deferred/SiteStatsUpdateTest.php2
-rw-r--r--tests/phpunit/includes/diff/DifferenceEngineTest.php3
18 files changed, 92 insertions, 77 deletions
diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php
index 8c07d571232c..a659c3ba51a1 100644
--- a/tests/phpunit/includes/cache/MessageCacheTest.php
+++ b/tests/phpunit/includes/cache/MessageCacheTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+use MediaWiki\MainConfigSchema;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use Wikimedia\TestingAccessWrapper;
@@ -134,15 +136,14 @@ class MessageCacheTest extends MediaWikiLangTestCase {
}
public function testReplaceCache() {
- global $wgWANObjectCaches;
-
// We need a WAN cache for this.
- $this->setMwGlobals( [
- 'wgMainWANCache' => 'hash',
- 'wgWANObjectCaches' => $wgWANObjectCaches + [
+ $this->overrideConfigValues( [
+ MainConfigNames::MainWANCache => CACHE_HASH,
+ MainConfigNames::WANObjectCaches =>
+ MainConfigSchema::getDefaultValue( MainConfigNames::WANObjectCaches ) + [
'hash' => [
'class' => WANObjectCache::class,
- 'cacheId' => 'hash',
+ 'cacheId' => CACHE_HASH,
'channels' => []
]
]
diff --git a/tests/phpunit/includes/changes/OldChangesListTest.php b/tests/phpunit/includes/changes/OldChangesListTest.php
index 780eb849d807..cd9ae19899c7 100644
--- a/tests/phpunit/includes/changes/OldChangesListTest.php
+++ b/tests/phpunit/includes/changes/OldChangesListTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @covers OldChangesList
*
@@ -21,9 +23,7 @@ class OldChangesListTest extends MediaWikiLangTestCase {
protected function setUp(): void {
parent::setUp();
- $this->setMwGlobals( [
- 'wgArticlePath' => '/wiki/$1',
- ] );
+ $this->overrideConfigValue( MainConfigNames::ArticlePath, '/wiki/$1' );
$this->setUserLang( 'qqx' );
$this->testRecentChangesHelper = new TestRecentChangesHelper();
}
diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index 829c24b33db3..091b2948d4f9 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\MainConfigNames;
/**
* @covers RCCacheEntryFactory
@@ -24,9 +25,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase {
protected function setUp(): void {
parent::setUp();
- $this->setMwGlobals( [
- 'wgArticlePath' => '/wiki/$1'
- ] );
+ $this->overrideConfigValue( MainConfigNames::ArticlePath, '/wiki/$1' );
$this->linkRenderer = $this->getServiceContainer()->getLinkRenderer();
$this->testRecentChangesHelper = new TestRecentChangesHelper();
diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php
index dbccc5d0f2b6..85e777fad9ce 100644
--- a/tests/phpunit/includes/changes/RecentChangeTest.php
+++ b/tests/phpunit/includes/changes/RecentChangeTest.php
@@ -1,5 +1,6 @@
<?php
+use MediaWiki\MainConfigNames;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\PageIdentityValue;
use MediaWiki\Page\PageReference;
@@ -375,7 +376,7 @@ class RecentChangeTest extends MediaWikiIntegrationTestCase {
* @dataProvider provideIsInRCLifespan
*/
public function testIsInRCLifespan( $maxAge, $offset, $tolerance, $expected ) {
- $this->setMwGlobals( 'wgRCMaxAge', $maxAge );
+ $this->overrideConfigValue( MainConfigNames::RCMaxAge, $maxAge );
// Calculate this here instead of the data provider because the provider
// is expanded early on and the full test suite may take longer than 100 minutes
// when coverage is enabled.
@@ -527,9 +528,7 @@ class RecentChangeTest extends MediaWikiIntegrationTestCase {
* @covers RecentChange::doMarkPatrolled
*/
public function testDoMarkPatrolledPermissions_NoRcPatrol() {
- $this->setMwGlobals( [
- 'wgUseRCPatrol' => false
- ] );
+ $this->overrideConfigValue( MainConfigNames::UseRCPatrol, false );
$rc = $this->getDummyEditRecentChange();
$errors = $rc->doMarkPatrolled( $this->mockRegisteredUltimateAuthority() );
$this->assertContains( [ 'rcpatroldisabled' ], $errors );
diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php
index b06c9531e6a9..27c74da051df 100644
--- a/tests/phpunit/includes/changetags/ChangeTagsTest.php
+++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @covers ChangeTags
* @group Database
@@ -43,7 +45,7 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
$modifiedQuery,
$exclude = false
) {
- $this->setMwGlobals( 'wgUseTagFilter', $useTags );
+ $this->overrideConfigValue( MainConfigNames::UseTagFilter, $useTags );
if ( $avoidReopeningTables && $this->db->getType() !== 'mysql' ) {
$this->markTestSkipped( 'MySQL only' );
@@ -468,7 +470,7 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
* @covers ChangeTags::getSoftwareTags
*/
public function testGetSoftwareTags( $softwareTags, $expected ) {
- $this->setMwGlobals( 'wgSoftwareTags', $softwareTags );
+ $this->overrideConfigValue( MainConfigNames::SoftwareTags, $softwareTags );
$actual = ChangeTags::getSoftwareTags();
// Order of tags in arrays is not important
diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php
index 3c409131b0b8..44f043f3e257 100644
--- a/tests/phpunit/includes/content/ContentHandlerTest.php
+++ b/tests/phpunit/includes/content/ContentHandlerTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Content\ValidationParams;
+use MediaWiki\MainConfigNames;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\PageIdentityValue;
use Wikimedia\TestingAccessWrapper;
@@ -14,17 +15,17 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
protected function setUp(): void {
parent::setUp();
- $this->setMwGlobals( [
- 'wgExtraNamespaces' => [
+ $this->overrideConfigValues( [
+ MainConfigNames::ExtraNamespaces => [
12312 => 'Dummy',
12313 => 'Dummy_talk',
],
// The below tests assume that namespaces not mentioned here (Help, User, MediaWiki, ..)
// default to CONTENT_MODEL_WIKITEXT.
- 'wgNamespaceContentModels' => [
+ MainConfigNames::NamespaceContentModels => [
12312 => 'testing',
],
- 'wgContentHandlers' => [
+ MainConfigNames::ContentHandlers => [
CONTENT_MODEL_WIKITEXT => WikitextContentHandler::class,
CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class,
CONTENT_MODEL_JSON => JsonContentHandler::class,
@@ -175,7 +176,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getContentText
*/
public function testGetContentText_Null( $contentHandlerTextFallback ) {
- $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
+ $this->overrideConfigValue( MainConfigNames::ContentHandlerTextFallback, $contentHandlerTextFallback );
$content = null;
@@ -196,7 +197,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getContentText
*/
public function testGetContentText_TextContent( $contentHandlerTextFallback ) {
- $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
+ $this->overrideConfigValue( MainConfigNames::ContentHandlerTextFallback, $contentHandlerTextFallback );
$content = new WikitextContent( "hello world" );
@@ -210,7 +211,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getContentText
*/
public function testGetContentText_NonTextContent_fail() {
- $this->setMwGlobals( 'wgContentHandlerTextFallback', 'fail' );
+ $this->overrideConfigValue( MainConfigNames::ContentHandlerTextFallback, 'fail' );
$content = new DummyContentForTesting( "hello world" );
@@ -222,7 +223,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getContentText
*/
public function testGetContentText_NonTextContent_serialize() {
- $this->setMwGlobals( 'wgContentHandlerTextFallback', 'serialize' );
+ $this->overrideConfigValue( MainConfigNames::ContentHandlerTextFallback, 'serialize' );
$content = new DummyContentForTesting( "hello world" );
@@ -234,7 +235,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getContentText
*/
public function testGetContentText_NonTextContent_ignore() {
- $this->setMwGlobals( 'wgContentHandlerTextFallback', 'ignore' );
+ $this->overrideConfigValue( MainConfigNames::ContentHandlerTextFallback, 'ignore' );
$content = new DummyContentForTesting( "hello world" );
@@ -347,7 +348,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
* @covers ContentHandler::getChangeTag
*/
public function testGetChangeTag() {
- $this->setMwGlobals( 'wgSoftwareTags', [ 'mw-contentmodelchange' => true ] );
+ $this->overrideConfigValue( MainConfigNames::SoftwareTags, [ 'mw-contentmodelchange' => true ] );
$wikitextContentHandler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
// Create old content object with javascript content model
$oldContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_JAVASCRIPT, null );
@@ -616,9 +617,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
$title = Title::newFromText( "SimpleTitle", $namespace );
- $this->setMwGlobals( [
- 'wgDefaultLanguageVariant' => $variant,
- ] );
+ $this->overrideConfigValue( MainConfigNames::DefaultLanguageVariant, $variant );
$this->setUserLang( $lang );
$this->setContentLang( $lang );
diff --git a/tests/phpunit/includes/content/CssContentHandlerTest.php b/tests/phpunit/includes/content/CssContentHandlerTest.php
index 728f01896c39..e3f99728aab8 100644
--- a/tests/phpunit/includes/content/CssContentHandlerTest.php
+++ b/tests/phpunit/includes/content/CssContentHandlerTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
class CssContentHandlerTest extends MediaWikiLangTestCase {
/**
@@ -7,9 +9,9 @@ class CssContentHandlerTest extends MediaWikiLangTestCase {
* @covers CssContentHandler::makeRedirectContent
*/
public function testMakeRedirectContent( $title, $expected ) {
- $this->setMwGlobals( [
- 'wgServer' => '//example.org',
- 'wgScript' => '/w/index.php',
+ $this->overrideConfigValues( [
+ MainConfigNames::Server => '//example.org',
+ MainConfigNames::Script => '/w/index.php',
] );
$ch = new CssContentHandler();
$content = $ch->makeRedirectContent( Title::newFromText( $title ) );
diff --git a/tests/phpunit/includes/content/CssContentTest.php b/tests/phpunit/includes/content/CssContentTest.php
index 408d24c6511c..bedb1361ee9a 100644
--- a/tests/phpunit/includes/content/CssContentTest.php
+++ b/tests/phpunit/includes/content/CssContentTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @group ContentHandler
* @group Database
@@ -10,11 +12,12 @@ class CssContentTest extends TextContentTest {
protected function setUp(): void {
parent::setUp();
- $this->setMwGlobals( [
- 'wgTextModelsToParse' => [
+ $this->overrideConfigValue(
+ MainConfigNames::TextModelsToParse,
+ [
CONTENT_MODEL_CSS,
]
- ] );
+ );
}
public function newContent( $text ) {
@@ -95,10 +98,10 @@ class CssContentTest extends TextContentTest {
* @dataProvider provideGetRedirectTarget
*/
public function testGetRedirectTarget( $title, $text ) {
- $this->setMwGlobals( [
- 'wgServer' => '//example.org',
- 'wgScriptPath' => '/w',
- 'wgScript' => '/w/index.php',
+ $this->overrideConfigValues( [
+ MainConfigNames::Server => '//example.org',
+ MainConfigNames::ScriptPath => '/w',
+ MainConfigNames::Script => '/w/index.php',
] );
$content = new CssContent( $text );
$target = $content->getRedirectTarget();
diff --git a/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php b/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
index c76f5a07a261..bdae210cebb1 100644
--- a/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
+++ b/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
/**
@@ -7,9 +9,9 @@ class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
* @covers JavaScriptContentHandler::makeRedirectContent
*/
public function testMakeRedirectContent( $title, $expected ) {
- $this->setMwGlobals( [
- 'wgServer' => '//example.org',
- 'wgScript' => '/w/index.php',
+ $this->overrideConfigValues( [
+ MainConfigNames::Server => '//example.org',
+ MainConfigNames::Script => '/w/index.php',
] );
$ch = new JavaScriptContentHandler();
$content = $ch->makeRedirectContent( Title::newFromText( $title ) );
diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php
index e8fff1e5422e..9352700f4413 100644
--- a/tests/phpunit/includes/content/JavaScriptContentTest.php
+++ b/tests/phpunit/includes/content/JavaScriptContentTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @group ContentHandler
* @group Database
@@ -208,11 +210,11 @@ class JavaScriptContentTest extends TextContentTest {
* @dataProvider provideUpdateRedirect
*/
public function testUpdateRedirect( $oldText, $expectedText ) {
- $this->setMwGlobals( [
- 'wgServer' => '//example.org',
- 'wgScriptPath' => '/w',
- 'wgScript' => '/w/index.php',
- 'wgResourceBasePath' => '/w',
+ $this->overrideConfigValues( [
+ MainConfigNames::Server => '//example.org',
+ MainConfigNames::ScriptPath => '/w',
+ MainConfigNames::Script => '/w/index.php',
+ MainConfigNames::ResourceBasePath => '/w',
] );
$target = Title::newFromText( "testUpdateRedirect_target" );
@@ -268,11 +270,11 @@ class JavaScriptContentTest extends TextContentTest {
* @dataProvider provideGetRedirectTarget
*/
public function testGetRedirectTarget( $title, $text ) {
- $this->setMwGlobals( [
- 'wgServer' => '//example.org',
- 'wgScriptPath' => '/w',
- 'wgScript' => '/w/index.php',
- 'wgResourceBasePath' => '/w',
+ $this->overrideConfigValues( [
+ MainConfigNames::Server => '//example.org',
+ MainConfigNames::ScriptPath => '/w',
+ MainConfigNames::Script => '/w/index.php',
+ MainConfigNames::ResourceBasePath => '/w',
] );
$content = new JavaScriptContent( $text );
$target = $content->getRedirectTarget();
diff --git a/tests/phpunit/includes/content/RegistrationContentHandlerFactoryToMediaWikiServicesTest.php b/tests/phpunit/includes/content/RegistrationContentHandlerFactoryToMediaWikiServicesTest.php
index 2290789965a0..f14ea738ec63 100644
--- a/tests/phpunit/includes/content/RegistrationContentHandlerFactoryToMediaWikiServicesTest.php
+++ b/tests/phpunit/includes/content/RegistrationContentHandlerFactoryToMediaWikiServicesTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @group ContentHandlerFactory
*/
@@ -8,8 +10,9 @@ class RegistrationContentHandlerFactoryToMediaWikiServicesTest extends MediaWiki
protected function setUp(): void {
parent::setUp();
- $this->setMwGlobals( [
- 'wgContentHandlers' => [
+ $this->overrideConfigValue(
+ MainConfigNames::ContentHandlers,
+ [
CONTENT_MODEL_WIKITEXT => WikitextContentHandler::class,
CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class,
CONTENT_MODEL_JSON => JsonContentHandler::class,
@@ -19,8 +22,8 @@ class RegistrationContentHandlerFactoryToMediaWikiServicesTest extends MediaWiki
'testing-callbacks' => static function ( $modelId ) {
return new DummyContentHandlerForTesting( $modelId );
},
- ],
- ] );
+ ]
+ );
$this->getServiceContainer()->resetServiceForTesting( 'ContentHandlerFactory' );
}
diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php
index b11c0c1a72fd..f0b3314f8d78 100644
--- a/tests/phpunit/includes/content/TextContentTest.php
+++ b/tests/phpunit/includes/content/TextContentTest.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MainConfigNames;
+
/**
* @group ContentHandler
* @group Database
@@ -25,15 +27,15 @@ class TextContentTest extends MediaWikiLangTestCase {
RequestContext::getMain()->setTitle( $this->context->getTitle() );
- $this->setMwGlobals( [
- 'wgTextModelsToParse' => [
+ $this->overrideConfigValues( [
+ MainConfigNames::TextModelsToParse => [
CONTENT_MODEL_WIKITEXT,
CONTENT_MODEL_CSS,
CONTENT_MODEL_JAVASCRIPT,
],
- 'wgCapitalLinks' => true,
- 'wgHooks' => [], // bypass hook ContentGetParserOutput that force custom rendering
+ MainConfigNames::CapitalLinks => true,
] );
+ $this->clearHook( 'ContentGetParserOutput' );
}
/**
@@ -97,7 +99,7 @@ class TextContentTest extends MediaWikiLangTestCase {
* @covers TextContent::isCountable
*/
public function testIsCountable( $text, $hasLinks, $mode, $expected ) {
- $this->setMwGlobals( 'wgArticleCountMethod', $mode );
+ $this->overrideConfigValue( MainConfigNames::ArticleCountMethod, $mode );
$content = $this->newContent( $text );
diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
index b1a9dff481be..558edcc32d48 100644
--- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php
+++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
@@ -1,5 +1,6 @@
<?php
+use MediaWiki\MainConfigNames;
use MediaWiki\Page\PageReferenceValue;
/**
@@ -247,7 +248,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
* @covers WikitextContentHandler::getChangeTag
*/
public function testGetChangeTag( $old, $new, $flags, $expected ) {
- $this->setMwGlobals( 'wgSoftwareTags', [
+ $this->overrideConfigValue( MainConfigNames::SoftwareTags, [
'mw-new-redirect' => true,
'mw-removed-redirect' => true,
'mw-changed-redirect-target' => true,
diff --git a/tests/phpunit/includes/debug/DeprecationHelperTest.php b/tests/phpunit/includes/debug/DeprecationHelperTest.php
index 1ea5a0884de9..d058e21fbcaf 100644
--- a/tests/phpunit/includes/debug/DeprecationHelperTest.php
+++ b/tests/phpunit/includes/debug/DeprecationHelperTest.php
@@ -1,5 +1,6 @@
<?php
+use MediaWiki\MainConfigNames;
use Wikimedia\TestingAccessWrapper;
/**
@@ -17,7 +18,7 @@ class DeprecationHelperTest extends MediaWikiIntegrationTestCase {
parent::setUp();
$this->testClass = new TestDeprecatedClass();
$this->testSubclass = new TestDeprecatedSubclass();
- $this->setMwGlobals( 'wgDevelopmentWarnings', false );
+ $this->overrideConfigValue( MainConfigNames::DevelopmentWarnings, false );
}
/**
diff --git a/tests/phpunit/includes/debug/logger/LegacyLoggerTest.php b/tests/phpunit/includes/debug/logger/LegacyLoggerTest.php
index 3652068ba7e3..4900c0512fb7 100644
--- a/tests/phpunit/includes/debug/logger/LegacyLoggerTest.php
+++ b/tests/phpunit/includes/debug/logger/LegacyLoggerTest.php
@@ -20,6 +20,7 @@
namespace MediaWiki\Logger;
+use MediaWiki\MainConfigNames;
use MediaWikiIntegrationTestCase;
use Psr\Log\LogLevel;
@@ -139,7 +140,7 @@ class LegacyLoggerTest extends MediaWikiIntegrationTestCase {
* @dataProvider provideShouldEmit
*/
public function testShouldEmit( $level, $config, $expected ) {
- $this->setMwGlobals( 'wgDebugLogGroups', [ 'fakechannel' => $config ] );
+ $this->overrideConfigValue( MainConfigNames::DebugLogGroups, [ 'fakechannel' => $config ] );
$this->assertEquals(
$expected,
LegacyLogger::shouldEmit( 'fakechannel', 'some message', $level, [] )
diff --git a/tests/phpunit/includes/deferred/LinksUpdateTest.php b/tests/phpunit/includes/deferred/LinksUpdateTest.php
index 44b81d7a62e9..f198b2b40061 100644
--- a/tests/phpunit/includes/deferred/LinksUpdateTest.php
+++ b/tests/phpunit/includes/deferred/LinksUpdateTest.php
@@ -3,6 +3,7 @@
use MediaWiki\Deferred\LinksUpdate\LinksTable;
use MediaWiki\Deferred\LinksUpdate\LinksTableGroup;
use MediaWiki\Deferred\LinksUpdate\LinksUpdate;
+use MediaWiki\MainConfigNames;
use MediaWiki\Page\PageIdentityValue;
use PHPUnit\Framework\MockObject\MockObject;
use Wikimedia\TestingAccessWrapper;
@@ -61,7 +62,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
'iw_wikiid' => 'linksupdatetest',
]
);
- $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
+ $this->overrideConfigValue( MainConfigNames::RCWatchCategoryMembership, true );
}
public function addDBDataOnce() {
@@ -237,7 +238,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
*/
public function testUpdate_categorylinks() {
/** @var ParserOutput $po */
- $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+ $this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
@@ -296,7 +297,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
}
public function testOnAddingAndRemovingCategory_recentChangesRowIsAdded() {
- $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+ $this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
$title = Title::newFromText( 'Testing' );
$wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
@@ -342,7 +343,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
}
public function testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored() {
- $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+ $this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
$templateTitle = Title::newFromText( 'Template:TestingTemplate' );
$templatePage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $templateTitle );
@@ -390,7 +391,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
}
public function testUpdate_categorylinks_move() {
- $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+ $this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
/** @var ParserOutput $po */
list( $t, $po ) = $this->makeTitleAndParserOutput( "Old", self::$testingPageId );
@@ -644,9 +645,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
* @covers ParserOutput::addLanguageLink
*/
public function testUpdate_langlinks() {
- $this->setMwGlobals( [
- 'wgCapitalLinks' => true,
- ] );
+ $this->overrideConfigValue( MainConfigNames::CapitalLinks, true );
/** @var ParserOutput $po */
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
diff --git a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php
index 06fcbcc3ae5f..d9a395cab268 100644
--- a/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php
+++ b/tests/phpunit/includes/deferred/SiteStatsUpdateTest.php
@@ -29,8 +29,6 @@ class SiteStatsUpdateTest extends MediaWikiIntegrationTestCase {
* @covers SiteStatsInit::refresh()
*/
public function testDoUpdate() {
- $this->setMwGlobals( 'wgSiteStatsAsyncFactor', false );
-
$dbw = wfGetDB( DB_PRIMARY );
$statsInit = new SiteStatsInit( $dbw );
$statsInit->refresh();
diff --git a/tests/phpunit/includes/diff/DifferenceEngineTest.php b/tests/phpunit/includes/diff/DifferenceEngineTest.php
index 4cf010cdaeb1..788e799ea3b3 100644
--- a/tests/phpunit/includes/diff/DifferenceEngineTest.php
+++ b/tests/phpunit/includes/diff/DifferenceEngineTest.php
@@ -1,5 +1,6 @@
<?php
+use MediaWiki\MainConfigNames;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
@@ -34,7 +35,7 @@ class DifferenceEngineTest extends MediaWikiIntegrationTestCase {
self::$revisions = $this->doEdits();
}
- $this->setMwGlobals( [ 'wgDiffEngine' => 'php' ] );
+ $this->overrideConfigValue( MainConfigNames::DiffEngine, 'php' );
$slotRoleRegistry = $this->getServiceContainer()->getSlotRoleRegistry();