Use overrideConfigValue/overrideConfigValues instead of setMwGlobals

Also use MainConfigNames.

Change-Id: I8014b6ca5fdf79c98da05981967d98bbbbaeef98
This commit is contained in:
Fomafix 2024-07-29 20:24:01 +00:00
parent b99d4d3773
commit bdf44ea4f7

View file

@ -20,6 +20,7 @@
*/ */
use MediaWiki\Config\GlobalVarConfig; use MediaWiki\Config\GlobalVarConfig;
use MediaWiki\MainConfigNames;
use MediaWiki\Title\Title; use MediaWiki\Title\Title;
use MediaWiki\User\Options\UserOptionsLookup; use MediaWiki\User\Options\UserOptionsLookup;
use MediaWiki\User\User; use MediaWiki\User\User;
@ -70,7 +71,7 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
* @param bool $expected * @param bool $expected
*/ */
public function testShowPreviewsPreferencesPage( array $config, $expected ) { public function testShowPreviewsPreferencesPage( array $config, $expected ) {
$this->setMwGlobals( $config ); $this->overrideConfigValues( $config );
$context = $this->getContext(); $context = $this->getContext();
$this->assertSame( $expected, $this->assertSame( $expected,
$context->showPreviewsOptInOnPreferencesPage(), $context->showPreviewsOptInOnPreferencesPage(),
@ -81,13 +82,13 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
return [ return [
[ [
[ [
'wgPopupsHideOptInOnPreferencesPage' => false 'PopupsHideOptInOnPreferencesPage' => false
], ],
true true
], ],
[ [
[ [
'wgPopupsHideOptInOnPreferencesPage' => true 'PopupsHideOptInOnPreferencesPage' => true
], ],
false false
] ]
@ -118,9 +119,7 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
* @param bool $expected * @param bool $expected
*/ */
public function testShouldSendModuleToUser( $optIn, $expected ) { public function testShouldSendModuleToUser( $optIn, $expected ) {
$this->setMwGlobals( [ $this->overrideConfigValue( 'PopupsReferencePreviews', false );
'wgPopupsReferencePreviews' => false,
] );
$user = $this->createMock( User::class ); $user = $this->createMock( User::class );
$user->method( 'isNamed' )->willReturn( true ); $user->method( 'isNamed' )->willReturn( true );
@ -160,9 +159,7 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
*/ */
public function testAreDependenciesMet( $textExtracts, $pageImages, public function testAreDependenciesMet( $textExtracts, $pageImages,
$gateway, $expected ) { $gateway, $expected ) {
$this->setMwGlobals( [ $this->overrideConfigValue( 'PopupsGateway', $gateway );
'wgPopupsGateway' => $gateway,
] );
$returnValues = [ $textExtracts, $pageImages ]; $returnValues = [ $textExtracts, $pageImages ];
$mock = $this->createMock( ExtensionRegistry::class ); $mock = $this->createMock( ExtensionRegistry::class );
@ -215,7 +212,7 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
* @param bool $expected * @param bool $expected
*/ */
public function testIsTitleExcluded( array $excludedPages, Title $title, $expected ) { public function testIsTitleExcluded( array $excludedPages, Title $title, $expected ) {
$this->setMwGlobals( [ 'wgPopupsPageDisabled' => $excludedPages ] ); $this->overrideConfigValue( 'PopupsPageDisabled', $excludedPages );
$context = $this->getContext(); $context = $this->getContext();
$this->assertSame( $expected, $this->assertSame( $expected,
$context->isTitleExcluded( $title ), $context->isTitleExcluded( $title ),
@ -245,9 +242,9 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
$page = 'Specjalna:Preferencje'; $page = 'Specjalna:Preferencje';
$excludedPages = [ 'Special:Preferences' ]; $excludedPages = [ 'Special:Preferences' ];
$this->setMwGlobals( [ $this->overrideConfigValues( [
'wgPopupsPageDisabled' => $excludedPages, 'PopupsPageDisabled' => $excludedPages,
'wgLanguageCode' => 'pl' MainConfigNames::LanguageCode => 'pl',
] ); ] );
$context = $this->getContext(); $context = $this->getContext();
$this->assertTrue( $this->assertTrue(