Skip to content

Commit

Permalink
Merge "Use more trivial NullLogger in tests, instead of mock"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 1, 2024
2 parents c98f4f1 + 0ae7e35 commit 3a33216
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Site\SiteLookup;
use MediaWikiIntegrationTestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Hooks\OtherProjectsSidebarGenerator;
use Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory;
use Wikibase\Client\Hooks\SidebarLinkBadgeDisplay;
Expand Down Expand Up @@ -38,7 +38,7 @@ public function testGetOtherProjectsSidebarGenerator() {
$this->createMock( EntityLookup::class ),
$this->createMock( SidebarLinkBadgeDisplay::class ),
$this->createMock( HookContainer::class ),
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$otherProjectSidebarGenerator = $factory->getOtherProjectsSidebarGenerator( $this->createMock( UsageAccumulator::class ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Site\SiteStore;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Hooks\LangLinkHandler;
use Wikibase\Client\Hooks\LangLinkHandlerFactory;
use Wikibase\Client\Hooks\LanguageLinkBadgeDisplay;
Expand Down Expand Up @@ -32,7 +32,7 @@ public function testGetLangLinkHandler() {
$this->createMock( EntityLookup::class ),
$this->createMock( SiteStore::class ),
$this->createMock( HookContainer::class ),
$this->createMock( LoggerInterface::class ),
new NullLogger(),
'srwiki',
[ 'wikipedia' ]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Title\Title;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Hooks\SiteLinksForDisplayLookup;
use Wikibase\Client\Usage\UsageAccumulator;
use Wikibase\DataModel\Entity\Item;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testGetSiteLinksForPageTitle_unknownTitle() {
$entityLookup,
$this->createMock( UsageAccumulator::class ),
$this->createMock( HookContainer::class ),
$this->createMock( LoggerInterface::class ),
new NullLogger(),
'srwiki'
);

Expand Down Expand Up @@ -73,7 +73,7 @@ public function testGetSiteLinksForPageTitle_unknownEntity() {
$entityLookup,
$this->createMock( UsageAccumulator::class ),
$this->createMock( HookContainer::class ),
$this->createMock( LoggerInterface::class ),
new NullLogger(),
'srwiki'
);

Expand Down Expand Up @@ -128,7 +128,7 @@ public function testGetSiteLinksForPageTitle_knownEntity() {
$entityLookup,
$this->createMock( UsageAccumulator::class ),
$hookContainer,
$this->createMock( LoggerInterface::class ),
new NullLogger(),
'srwiki'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Wikibase\Client\Tests\Unit\ServiceWiring;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Changes\AffectedPagesFinder;
use Wikibase\Client\Tests\Mocks\MockClientStore;
use Wikibase\Client\Tests\Unit\ServiceWiringTestCase;
Expand Down Expand Up @@ -32,7 +32,7 @@ public function testConstruction() {
);
$this->mockService(
'WikibaseClient.Logger',
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$this->serviceContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Wikibase\Client\Tests\Unit\ServiceWiring;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Changes\AffectedPagesFinder;
use Wikibase\Client\Changes\ChangeHandler;
use Wikibase\Client\Hooks\WikibaseClientHookRunner;
Expand Down Expand Up @@ -34,7 +34,7 @@ public function testConstruction(): void {

$this->mockService(
'WikibaseClient.Logger',
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$this->mockService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Wikibase\Client\Tests\Unit\ServiceWiring;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Client\Tests\Unit\ServiceWiringTestCase;
use Wikibase\Lib\Rdbms\RepoDomainDbFactory;
use Wikibase\Lib\Store\Sql\Terms\TermInLangIdsResolverFactory;
Expand All @@ -20,7 +20,7 @@ class TermInLangIdsResolverFactoryTest extends ServiceWiringTestCase {
public function testConstruction(): void {
$this->mockService(
'WikibaseClient.Logger',
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$this->mockService(
Expand Down
5 changes: 2 additions & 3 deletions lib/tests/phpunit/GlobalStateFactoryMethodsResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use MediaWiki\Http\HttpRequestFactory;
use MediaWikiIntegrationTestCase;
use ObjectCacheFactory;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Lib\StatsdRecordingSimpleCache;
use Wikibase\Lib\TermFallbackCache\TermFallbackCacheServiceFactory;
use Wikibase\Lib\TermFallbackCacheFactory;
Expand Down Expand Up @@ -67,10 +67,9 @@ public function testWikibaseSettings_repoSettings(): void {
* @dataProvider cacheTypeProvider
*/
public function testTermFallbackCacheFactory( $sharedCacheType ): void {
$logger = $this->createMock( LoggerInterface::class );
$factory = new TermFallbackCacheFactory(
$sharedCacheType,
$logger,
new NullLogger(),
$this->createMock( IBufferingStatsdDataFactory::class ),
'secret',
new TermFallbackCacheServiceFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use LogicException;
use MediaWiki\Revision\SlotRecord;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\DataAccess\DatabaseEntitySource;
use Wikibase\DataModel\Services\Term\ItemTermStoreWriter;
use Wikibase\DataModel\Services\Term\PropertyTermStoreWriter;
Expand Down Expand Up @@ -53,7 +53,7 @@ public function testFailsToCreateWriterWhenNotOnLocalEntitySource(
$this->newStubRepoDb(),
$this->createMock( WANObjectCache::class ),
$this->createMock( JobQueueGroup::class ),
$this->createMock( LoggerInterface::class )
new NullLogger()
);

if ( !$expected ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use MediaWiki\Utils\MWTimestamp;
use MediaWikiIntegrationTestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\Lib\Changes\RepoRevisionIdentifier;
Expand Down Expand Up @@ -54,7 +55,7 @@ public function testShouldDispatchJobsForClientWikis() {
new RepoRevisionIdentifier( "Q303", $timestamp, $revisionRecordId ),
];

$logger = $this->createMock( LoggerInterface::class );
$logger = new NullLogger();
$factory = $this->newJobQueueGroupFactory( $expectedRevIdentifiers );
$job = $this->getJobAndInitialize( $pageTitle, $params, $logger, $factory );

Expand Down
5 changes: 2 additions & 3 deletions repo/tests/phpunit/includes/WikibasePingbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use MediaWiki\SiteStats\SiteStatsInit;
use MediaWiki\Utils\MWTimestamp;
use MediaWikiIntegrationTestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
use TestLogger;
use Wikibase\Lib\Rdbms\RepoDomainDb;
use Wikibase\Lib\SettingsArray;
Expand Down Expand Up @@ -160,7 +160,6 @@ public function getPingbackWithRequestExpectation( $expectation, $logger ) {
}

private function getPingback( HttpRequestFactory $requestFactory = null ): WikibasePingback {
$logger = $this->createMock( LoggerInterface::class );
$extensions = $this->createMock( ExtensionRegistry::class );
$wikibaseRepoSettings = $this->createMock( SettingsArray::class );
$requestFactory ??= $this->createMock( HttpRequestFactory::class );
Expand All @@ -182,7 +181,7 @@ private function getPingback( HttpRequestFactory $requestFactory = null ): Wikib

return new WikibasePingback(
new HashConfig( [ MainConfigNames::DBtype => '' ] ),
$logger,
new NullLogger(),
$extensions,
$wikibaseRepoSettings,
$requestFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\DataModel\Services\EntityId\EntityIdComposer;
use Wikibase\Lib\Rdbms\RepoDomainDbFactory;
use Wikibase\Lib\Store\MatchingTermsLookupFactory;
Expand All @@ -26,7 +26,7 @@ public function testConstruction(): void {

$this->mockService(
'WikibaseRepo.Logger',
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$this->mockService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Wikibase\Repo\Tests\Unit\ServiceWiring;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikibase\Lib\Rdbms\RepoDomainDbFactory;
use Wikibase\Lib\Store\Sql\Terms\TermInLangIdsResolverFactory;
use Wikibase\Repo\Tests\Unit\ServiceWiringTestCase;
Expand All @@ -20,7 +20,7 @@ class TermInLangIdsResolverFactoryTest extends ServiceWiringTestCase {
public function testConstruction(): void {
$this->mockService(
'WikibaseRepo.Logger',
$this->createMock( LoggerInterface::class )
new NullLogger()
);

$this->serviceContainer
Expand Down

0 comments on commit 3a33216

Please sign in to comment.