tests: Use overrideConfig(Value|Values) where needed
This continues the work in the child patch to replace callers of setMwGlobals() with the appropriate method. Directory this patch covers is `tests/phpunit/integration/`. Change-Id: I0a9abf0d2a43587f2ffa029b68024a1ba5165fc7
This commit is contained in:
parent
5a98819809
commit
f88eab53a6
15 changed files with 71 additions and 57 deletions
|
|
@ -5,6 +5,7 @@ namespace MediaWiki\Tests\Rest\Handler;
|
|||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Interwiki\ClassicInterwikiLookup;
|
||||
use MediaWiki\Languages\LanguageNameUtils;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Rest\Handler\LanguageLinksHandler;
|
||||
use MediaWiki\Rest\LocalizedHttpException;
|
||||
|
|
@ -31,13 +32,14 @@ class LanguageLinksHandlerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$base = 'https://wiki.test/';
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgInterwikiCache' => ClassicInterwikiLookup::buildCdbHash( [
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::InterwikiCache,
|
||||
ClassicInterwikiLookup::buildCdbHash( [
|
||||
[ 'iw_prefix' => 'de', 'iw_url' => $base . '/de', 'iw_wikiid' => 'dewiki' ] + $defaults,
|
||||
[ 'iw_prefix' => 'en', 'iw_url' => $base . '/en', 'iw_wikiid' => 'enwiki' ] + $defaults,
|
||||
[ 'iw_prefix' => 'fr', 'iw_url' => $base . '/fr', 'iw_wikiid' => 'frwiki' ] + $defaults,
|
||||
] ),
|
||||
] );
|
||||
[ 'iw_prefix' => 'fr', 'iw_url' => $base . '/fr', 'iw_wikiid' => 'frwiki' ] + $defaults
|
||||
] )
|
||||
);
|
||||
|
||||
$this->editPage( __CLASS__ . '_Foo', 'Foo [[fr:Fou baux]] [[de:Füh bär]]' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,14 +388,15 @@ class PageHTMLHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
public function testStashingWithRateLimitExceeded() {
|
||||
// Set the rate limit to 1 request per minute
|
||||
$this->overrideConfigValue(
|
||||
'RateLimits',
|
||||
MainConfigNames::RateLimits,
|
||||
[
|
||||
'stashbasehtml' => [
|
||||
'&can-bypass' => false,
|
||||
'ip' => [ 1, 60 ],
|
||||
'newbie' => [ 1, 60 ]
|
||||
]
|
||||
] );
|
||||
]
|
||||
);
|
||||
$this->setMainCache( CACHE_HASH );
|
||||
|
||||
$page = $this->getExistingTestPage();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Exception;
|
|||
use ExtensionRegistry;
|
||||
use HashBagOStuff;
|
||||
use MediaWiki\Edit\SimpleParsoidOutputStash;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Page\PageRecord;
|
||||
use MediaWiki\Parser\Parsoid\ParsoidOutputAccess;
|
||||
use MediaWiki\Parser\Parsoid\ParsoidRenderID;
|
||||
|
|
@ -106,7 +107,7 @@ class ParsoidHTMLHelperTest extends MediaWikiIntegrationTestCase {
|
|||
$this->markTestSkipped( 'Parsoid is not configured' );
|
||||
}
|
||||
|
||||
$this->setMwGlobals( 'wgCacheEpoch', self::CACHE_EPOCH );
|
||||
$this->overrideConfigValue( MainConfigNames::CacheEpoch, self::CACHE_EPOCH );
|
||||
|
||||
// Clean up these tables after each test
|
||||
$this->tablesUsed = [
|
||||
|
|
|
|||
|
|
@ -412,14 +412,15 @@ class RevisionHTMLHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
public function testStashingWithRateLimitExceeded() {
|
||||
// Set the rate limit to 1 request per minute
|
||||
$this->overrideConfigValue(
|
||||
'RateLimits',
|
||||
MainConfigNames::RateLimits,
|
||||
[
|
||||
'stashbasehtml' => [
|
||||
'&can-bypass' => false,
|
||||
'ip' => [ 1, 60 ],
|
||||
'newbie' => [ 1, 60 ]
|
||||
]
|
||||
] );
|
||||
]
|
||||
);
|
||||
$this->setMainCache( CACHE_HASH );
|
||||
|
||||
$page = $this->getExistingTestPage();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
|
||||
/**
|
||||
* @group Templates
|
||||
* @coversDefaultClass TemplateParser
|
||||
|
|
@ -14,16 +16,14 @@ class TemplateParserIntegrationTest extends MediaWikiIntegrationTestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgSecretKey' => self::SECRET_KEY,
|
||||
] );
|
||||
$this->overrideConfigValue( MainConfigNames::SecretKey, self::SECRET_KEY );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getTemplate
|
||||
*/
|
||||
public function testGetTemplateNeverCacheWithoutSecretKey() {
|
||||
$this->setMwGlobals( 'wgSecretKey', false );
|
||||
$this->overrideConfigValue( MainConfigNames::SecretKey, false );
|
||||
|
||||
// Expect no cache interaction
|
||||
$cache = $this->createMock( BagOStuff::class );
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
|
||||
/**
|
||||
* @group small
|
||||
*/
|
||||
|
|
@ -9,9 +11,9 @@ class DifferenceEngineSlotDiffRendererIntegrationTest extends \MediaWikiIntegrat
|
|||
* @covers DifferenceEngineSlotDiffRenderer::getExtraCacheKeys
|
||||
*/
|
||||
public function testGetExtraCacheKeys_noExternalDiffEngineConfigured() {
|
||||
$this->setMwGlobals( [
|
||||
'wgDiffEngine' => null,
|
||||
'wgExternalDiffEngine' => null,
|
||||
$this->overrideConfigValues( [
|
||||
MainConfigNames::DiffEngine => null,
|
||||
MainConfigNames::ExternalDiffEngine => null,
|
||||
] );
|
||||
|
||||
$differenceEngine = new CustomDifferenceEngine();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace MediaWiki\Tests\Export;
|
|||
|
||||
use FactoryArgTestTrait;
|
||||
use MediaWiki\Export\WikiExporterFactory;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use WikiExporter;
|
||||
use XmlDumpWriter;
|
||||
|
|
@ -16,9 +17,10 @@ class WikiExporterFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->setMwGlobals( [
|
||||
'XmlDumpSchemaVersion' => XmlDumpWriter::$supportedSchemas[0],
|
||||
] );
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::XmlDumpSchemaVersion,
|
||||
XmlDumpWriter::$supportedSchemas[0]
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getFactoryClass() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace MediaWiki\Tests\Log;
|
|||
|
||||
use DatabaseLogEntry;
|
||||
use LogPage;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\User\UserIdentityValue;
|
||||
use MockTitleTrait;
|
||||
|
||||
|
|
@ -18,14 +19,14 @@ class LogPageTest extends \MediaWikiIntegrationTestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgLogNames' => [
|
||||
$this->overrideConfigValues( [
|
||||
MainConfigNames::LogNames => [
|
||||
'test_test' => 'testing-log-message'
|
||||
],
|
||||
'wgLogHeaders' => [
|
||||
MainConfigNames::LogHeaders => [
|
||||
'test_test' => 'testing-log-header'
|
||||
],
|
||||
'wgLogRestrictions' => [
|
||||
MainConfigNames::LogRestrictions => [
|
||||
'test_test' => 'testing-log-restriction'
|
||||
]
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use CommentStoreComment;
|
|||
use Content;
|
||||
use ContentHandler;
|
||||
use DeferredUpdates;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Page\DeletePage;
|
||||
use MediaWiki\Page\ProperPageIdentity;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
|
|
@ -269,9 +270,7 @@ class DeletePageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
if ( !$immediate ) {
|
||||
// Ensure that the job queue can be used
|
||||
$this->setMwGlobals( [
|
||||
'wgDeleteRevisionsBatchSize' => 1
|
||||
] );
|
||||
$this->overrideConfigValue( MainConfigNames::DeleteRevisionsBatchSize, 1 );
|
||||
$this->editPage( $page, "second revision" );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace MediaWiki\Tests\Page;
|
|||
use ChangeTags;
|
||||
use DatabaseLogEntry;
|
||||
use JsonContent;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Page\PageIdentityValue;
|
||||
use MediaWiki\Page\RollbackPage;
|
||||
|
|
@ -36,7 +37,7 @@ class RollbackPageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->setMwGlobals( 'wgUseRCPatrol', true );
|
||||
$this->overrideConfigValue( MainConfigNames::UseRCPatrol, true );
|
||||
$this->tablesUsed = array_merge( $this->tablesUsed, [
|
||||
'page',
|
||||
'recentchanges',
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace MediaWiki\Tests\User;
|
|||
use CannotCreateActorException;
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\DAO\WikiAwareEntity;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\ActorStore;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
|
|
@ -781,9 +782,10 @@ class ActorStoreTest extends ActorStoreTestBase {
|
|||
* @covers ::acquireSystemActorId
|
||||
*/
|
||||
public function testAcquireSystemActorId_replaceReserved() {
|
||||
$this->setMwGlobals( [
|
||||
'wgReservedUsernames' => [ 'RESERVED' ],
|
||||
] );
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::ReservedUsernames,
|
||||
[ 'RESERVED' ]
|
||||
);
|
||||
$store = $this->getStore();
|
||||
$originalActor = new UserIdentityValue( 0, 'RESERVED' );
|
||||
$actorId = $store->createNewActor( $originalActor, $this->db );
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace MediaWiki\Tests\User\TempUser;
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\User\TempUser\RealTempUserConfig
|
||||
* @group Database
|
||||
|
|
@ -67,9 +69,7 @@ class RealTempUserConfigTest extends \MediaWikiIntegrationTestCase {
|
|||
* @param bool $expected
|
||||
*/
|
||||
public function testIsAutoCreateAction( $config, $action, $expected ) {
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => $config
|
||||
] );
|
||||
$this->overrideConfigValue( MainConfigNames::AutoCreateTempUser, $config );
|
||||
$tuc = $this->getServiceContainer()->getTempUserConfig();
|
||||
$this->assertSame( $expected, $tuc->isAutoCreateAction( $action ) );
|
||||
}
|
||||
|
|
@ -106,17 +106,16 @@ class RealTempUserConfigTest extends \MediaWikiIntegrationTestCase {
|
|||
* @param bool $expected
|
||||
*/
|
||||
public function testIsReservedName( $config, $name, $expected ) {
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => $config
|
||||
] );
|
||||
$this->overrideConfigValue( MainConfigNames::AutoCreateTempUser, $config );
|
||||
$tuc = $this->getServiceContainer()->getTempUserConfig();
|
||||
$this->assertSame( $expected, $tuc->isReservedName( $name ) );
|
||||
}
|
||||
|
||||
private function getTempUserConfig() {
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => [ 'enabled' => true ] + self::DEFAULTS
|
||||
] );
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::AutoCreateTempUser,
|
||||
[ 'enabled' => true ] + self::DEFAULTS
|
||||
);
|
||||
return $this->getServiceContainer()->getTempUserConfig();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace MediaWiki\Tests\User\TempUser;
|
|||
|
||||
use ExtensionRegistry;
|
||||
use MediaWiki\Auth\AuthManager;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Session\Session;
|
||||
use MediaWiki\User\TempUser\RealTempUserConfig;
|
||||
use MediaWiki\User\TempUser\SerialMapping;
|
||||
|
|
@ -34,8 +35,9 @@ class TempUserCreatorTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->tablesUsed[] = 'user';
|
||||
$this->tablesUsed[] = 'user_autocreate_serial';
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => [
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::AutoCreateTempUser,
|
||||
[
|
||||
'enabled' => true,
|
||||
'actions' => [ 'edit' ],
|
||||
'genPattern' => '*Unregistered $1',
|
||||
|
|
@ -43,7 +45,7 @@ class TempUserCreatorTest extends \MediaWikiIntegrationTestCase {
|
|||
'serialProvider' => [ 'type' => 'local' ],
|
||||
'serialMapping' => [ 'type' => 'plain-numeric' ]
|
||||
]
|
||||
] );
|
||||
);
|
||||
$tuc = $this->getServiceContainer()->getTempUserCreator();
|
||||
$this->assertTrue( $tuc->isAutoCreateAction( 'edit' ) );
|
||||
$this->assertTrue( $tuc->isReservedName( '*Unregistered 1' ) );
|
||||
|
|
@ -111,11 +113,10 @@ class TempUserCreatorTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
public function testAcquireName_db() {
|
||||
$this->tablesUsed[] = 'user_autocreate_serial';
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => [
|
||||
'enabled' => true,
|
||||
] + self::DEFAULTS
|
||||
] );
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::AutoCreateTempUser,
|
||||
[ 'enabled' => true ] + self::DEFAULTS
|
||||
);
|
||||
$tuc = TestingAccessWrapper::newFromObject(
|
||||
$this->getServiceContainer()->getTempUserCreator()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Permissions\UltimateAuthority;
|
||||
use MediaWiki\User\UserFactory;
|
||||
use MediaWiki\User\UserIdentityValue;
|
||||
|
|
@ -186,8 +187,9 @@ class UserFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testNewTempPlaceholder() {
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => [
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::AutoCreateTempUser,
|
||||
[
|
||||
'enabled' => true,
|
||||
'actions' => [ 'edit' ],
|
||||
'genPattern' => '*Unregistered $1',
|
||||
|
|
@ -195,7 +197,7 @@ class UserFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
'serialProvider' => [ 'type' => 'local' ],
|
||||
'serialMapping' => [ 'type' => 'plain-numeric' ],
|
||||
]
|
||||
] );
|
||||
);
|
||||
$user = $this->getUserFactory()->newTempPlaceholder();
|
||||
$this->assertTrue( $user->isTemp() );
|
||||
$this->assertFalse( $user->isRegistered() );
|
||||
|
|
@ -204,8 +206,9 @@ class UserFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testNewUnsavedTempUser() {
|
||||
$this->setMwGlobals( [
|
||||
'wgAutoCreateTempUser' => [
|
||||
$this->overrideConfigValue(
|
||||
MainConfigNames::AutoCreateTempUser,
|
||||
[
|
||||
'enabled' => true,
|
||||
'actions' => [ 'edit' ],
|
||||
'genPattern' => '*Unregistered $1',
|
||||
|
|
@ -213,7 +216,7 @@ class UserFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
'serialProvider' => [ 'type' => 'local' ],
|
||||
'serialMapping' => [ 'type' => 'plain-numeric' ],
|
||||
]
|
||||
] );
|
||||
);
|
||||
$user = $this->getUserFactory()->newUnsavedTempUser( '*Unregistered 1234' );
|
||||
$this->assertTrue( $user->isTemp() );
|
||||
$this->assertFalse( $user->isNamed() );
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Tests\User;
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\User\UserGroupManager;
|
||||
use MediaWiki\User\UserGroupManagerFactory;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
|
|
@ -20,9 +21,7 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgLocalDatabases' => [ 'foowiki' ],
|
||||
] );
|
||||
$this->overrideConfigValue( MainConfigNames::LocalDatabases, [ 'foowiki' ] );
|
||||
|
||||
$dbMock = $this->createMock( DBConnRef::class );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue