Merge "Use overrideConfigValue/overrideConfigValues instead of setMwGlobals"

This commit is contained in:
jenkins-bot 2024-07-28 13:45:00 +00:00 committed by Gerrit Code Review
commit 777c649f96
8 changed files with 30 additions and 31 deletions

View file

@ -18,9 +18,9 @@ class ApiEchoPushSubscriptionsCreateTest extends ApiTestCase {
protected function setUp(): void {
parent::setUp();
$this->setMwGlobals( [
'wgEchoEnablePush' => true,
'wgEchoPushMaxSubscriptionsPerUser' => 2
$this->overrideConfigValues( [
'EchoEnablePush' => true,
'EchoPushMaxSubscriptionsPerUser' => 2,
] );
$this->user = $this->getTestUser()->getUser();
$this->createTestData();

View file

@ -24,9 +24,9 @@ class ApiEchoPushSubscriptionsDeleteTest extends ApiTestCase {
protected function setUp(): void {
parent::setUp();
$this->setMwGlobals( [
'wgEchoEnablePush' => true,
'wgEchoPushMaxSubscriptionsPerUser' => 3
$this->overrideConfigValues( [
'EchoEnablePush' => true,
'EchoPushMaxSubscriptionsPerUser' => 3,
] );
// Use mutable users for our generic users so we don't get two references to the same User

View file

@ -10,7 +10,7 @@ use MediaWiki\Tests\Api\ApiTestCase;
class ApiEchoPushSubscriptionsTest extends ApiTestCase {
public function testRequiresToken(): void {
$this->setMwGlobals( 'wgEchoEnablePush', true );
$this->overrideConfigValue( 'EchoEnablePush', true );
$params = [
'action' => 'echopushsubscriptions',
'command' => 'create',

View file

@ -81,11 +81,9 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
* @dataProvider evaluateUserLocatorsProvider
*/
public function testEvaluateUserLocators( $message, $expect, $locatorConfigForEventType, $setup = null ) {
$this->setMwGlobals( [
'wgEchoNotifications' => [
'unit-test' => [
AttributeManager::ATTR_LOCATORS => $locatorConfigForEventType
],
$this->overrideConfigValue( 'EchoNotifications', [
'unit-test' => [
AttributeManager::ATTR_LOCATORS => $locatorConfigForEventType
],
] );
@ -153,13 +151,11 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
$expect,
$users
) {
$this->setMwGlobals( [
'wgEchoNotifications' => [
'unit-test' => [
AttributeManager::ATTR_LOCATORS => static function () use ( $users ) {
return $users;
},
],
$this->overrideConfigValue( 'EchoNotifications', [
'unit-test' => [
AttributeManager::ATTR_LOCATORS => static function () use ( $users ) {
return $users;
},
],
] );
@ -249,11 +245,11 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
array $notifyTypeAvailabilityByCategory,
array $notifications
) {
$this->setMwGlobals( [
'wgDefaultNotifyTypeAvailability' => $defaultNotifyTypeAvailability,
'wgNotifyTypeAvailabilityByCategory' => $notifyTypeAvailabilityByCategory,
'wgEchoNotifications' => $notifications,
'wgEchoNotificationCategories' => array_fill_keys(
$this->overrideConfigValues( [
'DefaultNotifyTypeAvailability' => $defaultNotifyTypeAvailability,
'NotifyTypeAvailabilityByCategory' => $notifyTypeAvailabilityByCategory,
'EchoNotifications' => $notifications,
'EchoNotificationCategories' => array_fill_keys(
array_keys( $notifyTypeAvailabilityByCategory ),
[ 'priority' => 4 ]
),

View file

@ -2,14 +2,15 @@
use MediaWiki\Extension\Notifications\Hooks as EchoHooks;
use MediaWiki\Extension\Notifications\Services;
use MediaWiki\MainConfigNames;
class EchoHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers \MediaWiki\Extension\Notifications\Hooks::onUserGetDefaultOptions()
*/
public function testOnUserGetDefaultOptions() {
$this->setMwGlobals( [
'wgEchoNotificationCategories' => [
$this->overrideConfigValues( [
'EchoNotificationCategories' => [
'emailuser' => [
'priority' => 9,
'tooltip' => 'echo-pref-tooltip-emailuser',
@ -28,7 +29,7 @@ class EchoHooksTest extends MediaWikiIntegrationTestCase {
'priority' => 9001,
],
],
'wgAllowHTMLEmail' => true,
MainConfigNames::AllowHTMLEmail => true,
] );
$defaults = [

View file

@ -3,6 +3,7 @@
use MediaWiki\Extension\Notifications\DbFactory;
use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
use MediaWiki\Extension\Notifications\Model\Notification;
use MediaWiki\MainConfigNames;
use MediaWiki\User\User;
use Wikimedia\Rdbms\DeleteQueryBuilder;
use Wikimedia\Rdbms\FakeResultWrapper;
@ -114,7 +115,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
}
public function testDeleteByUserEventOffset() {
$this->setMwGlobals( [ 'wgUpdateRowsPerQuery' => 4 ] );
$this->overrideConfigValue( MainConfigNames::UpdateRowsPerQuery, 4 );
$mockDb = $this->createMock( IDatabase::class );
$makeResultRows = static function ( $eventIds ) {
return new FakeResultWrapper( array_map( static function ( $eventId ) {

View file

@ -7,6 +7,7 @@ use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper;
use MediaWiki\Extension\Notifications\Model\Event;
use MediaWiki\Extension\Notifications\Model\Notification;
use MediaWiki\Extension\Notifications\NotifUser;
use MediaWiki\MainConfigNames;
use MediaWiki\User\Options\UserOptionsLookup;
use MediaWiki\User\TalkPageNotificationManager;
use MediaWiki\User\User;
@ -58,9 +59,9 @@ class NotifUserTest extends MediaWikiIntegrationTestCase {
$this->setService( 'UserOptionsLookup', $userOptionsLookup );
$notifUser = NotifUser::newFromUser( $user );
$this->setMwGlobals( 'wgAllowHTMLEmail', true );
$this->overrideConfigValue( MainConfigNames::AllowHTMLEmail, true );
$this->assertEquals( $notifUser->getEmailFormat(), $pref );
$this->setMwGlobals( 'wgAllowHTMLEmail', false );
$this->overrideConfigValue( MainConfigNames::AllowHTMLEmail, false );
$this->assertEquals( EmailFormat::PLAIN_TEXT, $notifUser->getEmailFormat() );
}

View file

@ -12,7 +12,7 @@ class SubscriptionManagerTest extends MediaWikiIntegrationTestCase {
protected function setUp(): void {
parent::setUp();
$this->setMwGlobals( 'wgEchoPushMaxSubscriptionsPerUser', 1 );
$this->overrideConfigValue( 'EchoPushMaxSubscriptionsPerUser', 1 );
}
public function testManagePushSubscriptions(): void {