Skip to content

Commit

Permalink
Merge "Use named MainConfigNames constants instead of strings"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 13, 2024
2 parents a9ed96a + 570ea0a commit f6edfe5
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Wikibase\Client\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Wikibase\Client\Store\ClientStore;
use Wikibase\Client\Tests\Unit\ServiceWiringTestCase;
use Wikibase\DataAccess\NullPrefetchingTermLookup;
Expand Down Expand Up @@ -65,9 +66,7 @@ public function testWithoutKartographer(): void {
null );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'ThumbLimits' => [],
] ) );
->willReturn( new HashConfig( [ MainConfigNames::ThumbLimits => [] ] ) );

$this->assertInstanceOf(
WikibaseValueFormatterBuilders::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Wikibase\Client\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Psr\Log\NullLogger;
use Wikibase\Client\Tests\Unit\ServiceWiringTestCase;
use Wikibase\Lib\SettingsArray;
Expand Down Expand Up @@ -32,9 +33,7 @@ public function testConstruction(): void {
->willReturn( new NullStatsdDataFactory() );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'SecretKey' => 'not so secret',
] ) );
->willReturn( new HashConfig( [ MainConfigNames::SecretKey => 'not so secret' ] ) );

$termFallbackCacheFactory = $this->getService( 'WikibaseClient.TermFallbackCacheFactory' );

Expand Down
20 changes: 10 additions & 10 deletions repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Article;
use MediaWiki\Config\HashConfig;
use MediaWiki\Context\IContextSource;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Output\OutputPage;
use MediaWiki\Request\WebRequest;
Expand Down Expand Up @@ -69,16 +70,15 @@ private function getContext( MockObject $output ) {
$context = $this->createMock( IContextSource::class );
$context->method( 'getConfig' )
->willReturn( new HashConfig( [
'UseFileCache' => false,
'UseMediaWikiUIEverywhere' => false,
'Localtimezone' => 'UTC',
'ShowUpdatedMarker' => true,
'LogRestrictions' => [],
'UserrightsInterwikiDelimiter' => '@',
'MiserMode' => true,
'ActionFilteredLogs' => [],
'MaxExecutionTimeForExpensiveQueries' => 0,
'Send404Code' => true,
MainConfigNames::UseFileCache => false,
MainConfigNames::Localtimezone => 'UTC',
MainConfigNames::ShowUpdatedMarker => true,
MainConfigNames::LogRestrictions => [],
MainConfigNames::UserrightsInterwikiDelimiter => '@',
MainConfigNames::MiserMode => true,
MainConfigNames::ActionFilteredLogs => [],
MainConfigNames::MaxExecutionTimeForExpensiveQueries => 0,
MainConfigNames::Send404Code => true,
] ) );
$context->method( 'getRequest' )
->willReturn( new WebRequest() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Wikibase\Repo\Tests;

use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\TempUser\TempUserConfig;
use MediaWikiIntegrationTestCase;
Expand All @@ -18,7 +19,7 @@
class AnonymousEditWarningBuilderTest extends MediaWikiIntegrationTestCase {

public function testBuildAnonymousEditWarningHTML(): void {
$this->overrideConfigValue( 'LanguageCode', 'qqx' );
$this->overrideConfigValue( MainConfigNames::LanguageCode, 'qqx' );
$tempUserConfig = $this->createMock( TempUserConfig::class );
$tempUserConfig->expects( $this->once() )
->method( 'isEnabled' )
Expand All @@ -45,7 +46,7 @@ public function testBuildAnonymousEditWarningHTML(): void {
}

public function testBuildAnonymousEditWarningHTMLTempUsers(): void {
$this->overrideConfigValue( 'LanguageCode', 'qqx' );
$this->overrideConfigValue( MainConfigNames::LanguageCode, 'qqx' );
$tempUserConfig = $this->createMock( TempUserConfig::class );
$tempUserConfig->expects( $this->once() )
->method( 'isEnabled' )
Expand Down
3 changes: 2 additions & 1 deletion repo/tests/phpunit/includes/Api/RemoveClaimsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DataValues\StringValue;
use MediaWiki\Api\ApiUsageException;
use MediaWiki\MainConfigNames;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Services\Statement\GuidGenerator;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function itemProvider(): iterable {
}

public function testValidRequests() {
$this->overrideConfigValue( 'RateLimits',
$this->overrideConfigValue( MainConfigNames::RateLimits,
[ 'edit' => [ '&can-bypass' => true, 'user' => [ 1000, 60 ] ] ] );
foreach ( $this->itemProvider() as $item ) {
$this->doTestValidRequestSingle( $item );
Expand Down
3 changes: 2 additions & 1 deletion repo/tests/phpunit/includes/Api/SetClaimTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use MediaWiki\Api\ApiMessage;
use MediaWiki\Api\ApiUsageException;
use MediaWiki\Json\FormatJson;
use MediaWiki\MainConfigNames;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\Item;
Expand Down Expand Up @@ -118,7 +119,7 @@ private function getStatements(): array {
}

public function testAddClaim() {
$this->overrideConfigValue( 'RateLimits',
$this->overrideConfigValue( MainConfigNames::RateLimits,
[ 'wikibase-idgenerator' => [ '&can-bypass' => true, 'user' => [ 1000, 60 ] ] ] );
$store = $this->getEntityStore();
$guidGenerator = new GuidGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Wikibase\DataModel\Services\EntityId\SuffixEntityIdParser;
use Wikibase\DataModel\Services\Lookup\EntityLookup;
use Wikibase\DataModel\Services\Lookup\TermLookup;
Expand Down Expand Up @@ -33,9 +34,7 @@ public function testConstruction(): void {
$this->serviceContainer
->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'ThumbLimits' => [],
] ) );
->willReturn( new HashConfig( [ MainConfigNames::ThumbLimits => [] ] ) );

$this->mockService(
'WikibaseRepo.Settings',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Wikibase\Lib\Store\EntityNamespaceLookup;
use Wikibase\Lib\Store\EntityTitleLookup;
use Wikibase\Repo\Store\WikiPageEntityStorePermissionChecker;
Expand All @@ -28,7 +29,7 @@ public function testConstruction(): void {
->method( 'getPermissionManager' );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [ 'AvailableRights' => [] ] ) );
->willReturn( new HashConfig( [ MainConfigNames::AvailableRights => [] ] ) );

$this->assertInstanceOf(
WikiPageEntityStorePermissionChecker::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use LogicException;
use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Psr\Log\NullLogger;
use Wikibase\DataAccess\EntitySourceDefinitions;
use Wikibase\DataAccess\Tests\NewDatabaseEntitySource;
Expand Down Expand Up @@ -38,9 +39,7 @@ public function testFederatedPropertiesEnabled(): void {
new DataTypeDefinitions( [] ) );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'ServerName' => 'https://other-wiki.example/w/',
] ) );
->willReturn( new HashConfig( [ MainConfigNames::ServerName => 'https://other-wiki.example/w/' ] ) );
$source = NewDatabaseEntitySource::havingName( 'some source' )
->withConceptBaseUri( 'http://wikidata.org/entity/' )
->build();
Expand Down
5 changes: 2 additions & 3 deletions repo/tests/phpunit/unit/ServiceWiring/RdfVocabularyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Wikibase\DataAccess\DatabaseEntitySource;
use Wikibase\DataAccess\EntitySourceDefinitions;
use Wikibase\DataModel\Entity\Property;
Expand Down Expand Up @@ -61,9 +62,7 @@ public function testConstruction(): void {
] ) );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'DummyLanguageCodes' => [ 'd1' => 'dummy-1' ],
] ) );
->willReturn( new HashConfig( [ MainConfigNames::DummyLanguageCodes => [ 'd1' => 'dummy-1' ] ] ) );
$this->serviceContainer->expects( $this->once() )
->method( 'getTitleFactory' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use MediaWiki\Site\HashSiteStore;
use Wikibase\Repo\SiteLinkGlobalIdentifiersProvider;
use Wikibase\Repo\SiteLinkTargetProvider;
Expand All @@ -29,9 +30,7 @@ public function testConstruction(): void {
$this->serviceContainer
->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'SecretKey' => 'Foo',
] ) );
->willReturn( new HashConfig( [ MainConfigNames::SecretKey => 'Foo' ] ) );

$this->assertInstanceOf(
SiteLinkGlobalIdentifiersProvider::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use Psr\Log\NullLogger;
use Wikibase\Lib\SettingsArray;
use Wikibase\Lib\TermFallbackCacheFactory;
Expand Down Expand Up @@ -32,9 +33,7 @@ public function testConstruction(): void {
->willReturn( new NullStatsdDataFactory() );
$this->serviceContainer->expects( $this->once() )
->method( 'getMainConfig' )
->willReturn( new HashConfig( [
'SecretKey' => 'not so secret',
] ) );
->willReturn( new HashConfig( [ MainConfigNames::SecretKey => 'not so secret' ] ) );
$this->serviceContainer->expects( $this->once() )
->method( 'getObjectCacheFactory' );

Expand Down

0 comments on commit f6edfe5

Please sign in to comment.