diff --git a/client/tests/phpunit/integration/includes/Hooks/ParserOutputUpdateHookHandlerTest.php b/client/tests/phpunit/integration/includes/Hooks/ParserOutputUpdateHookHandlerTest.php index 78d454dff68..367496c104b 100644 --- a/client/tests/phpunit/integration/includes/Hooks/ParserOutputUpdateHookHandlerTest.php +++ b/client/tests/phpunit/integration/includes/Hooks/ParserOutputUpdateHookHandlerTest.php @@ -44,6 +44,7 @@ use Wikibase\Lib\SettingsArray; use Wikibase\Lib\Store\SiteLinkLookup; use Wikibase\Lib\Tests\MockRepository; +use Wikimedia\TestingAccessWrapper; /** * @covers \Wikibase\Client\Hooks\ParserOutputUpdateHookHandler @@ -320,6 +321,8 @@ public function testDoContentAlterParserOutput( array $expectedSisterLinks, array $expectedBadges = null ) { + $titleWrapper = TestingAccessWrapper::newFromObject( $title ); + $titleWrapper->mRedirect = false; $content = $this->createMock( Content::class ); $parserOutput = $this->newParserOutput( $extensionDataAppend, [] ); $handler = $this->newParserOutputUpdateHookHandler( $this->getTestSiteLinkData() ); @@ -420,6 +423,8 @@ public function testGivenSitelinkHasStatementWithUnknownEntityType_linkDataIsAdd $content = $this->createMock( Content::class ); $title = Title::makeTitle( NS_MAIN, 'Foobarium' ); + $titleWrapper = TestingAccessWrapper::newFromObject( $title ); + $titleWrapper->mRedirect = false; $parserOutput = $this->newParserOutput( [], [] ); diff --git a/lib/tests/phpunit/Formatters/AutoCommentFormatterTest.php b/lib/tests/phpunit/Formatters/AutoCommentFormatterTest.php index 5a0069c2def..82e88bd9633 100644 --- a/lib/tests/phpunit/Formatters/AutoCommentFormatterTest.php +++ b/lib/tests/phpunit/Formatters/AutoCommentFormatterTest.php @@ -58,6 +58,8 @@ public static function provideTestAutoComment() { * @dataProvider provideTestAutoComment */ public function testFormatAutoComment( array $prefixes, $auto, $expected ) { + // If the Translate extension is installed, its handler for ParserBeforeInternalParse can trigger DB access + $this->clearHook( 'ParserBeforeInternalParse' ); $formatter = new AutoCommentFormatter( $this->language, $prefixes ); $value = $formatter->formatAutoComment( $auto ); $this->assertEquals( $expected, $value ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/AddItemStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/AddItemStatementRouteHandlerTest.php index fa5b84e023a..200b95e361f 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/AddItemStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/AddItemStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class AddItemStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( AddItemStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/GetItemStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/GetItemStatementRouteHandlerTest.php index 69e8d02ad78..dd4c2c9a7d1 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/GetItemStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/GetItemStatementRouteHandlerTest.php @@ -21,6 +21,7 @@ * @covers \Wikibase\Repo\RestApi\RouteHandlers\GetItemStatementRouteHandler * * @group Wikibase + * @group Database * * @license GPL-2.0-or-later */ diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/GetPropertyStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/GetPropertyStatementRouteHandlerTest.php index 1a6016273f2..dd71e88005b 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/GetPropertyStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/GetPropertyStatementRouteHandlerTest.php @@ -20,6 +20,7 @@ * @covers \Wikibase\Repo\RestApi\RouteHandlers\GetPropertyStatementRouteHandler * * @group Wikibase + * @group Database * * @license GPL-2.0-or-later */ diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemLabelsRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemLabelsRouteHandlerTest.php index cceaa1ef99c..455bba3f372 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemLabelsRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemLabelsRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class PatchItemLabelsRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( PatchItemLabels::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemStatementRouteHandlerTest.php index b424b6fa0f3..2509fd159e8 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/PatchItemStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class PatchItemStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( PatchItemStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/PatchStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/PatchStatementRouteHandlerTest.php index a341546c4b4..05b33bacf3d 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/PatchStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/PatchStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class PatchStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( PatchItemStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/RemoveItemStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/RemoveItemStatementRouteHandlerTest.php index 5c4ff798959..823b2863603 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/RemoveItemStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/RemoveItemStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class RemoveItemStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( RemoveItemStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/RemoveStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/RemoveStatementRouteHandlerTest.php index df536acad61..3434d2d5a0a 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/RemoveStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/RemoveStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class RemoveStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( RemoveItemStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceItemStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceItemStatementRouteHandlerTest.php index a686125c998..6d2bbe67060 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceItemStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceItemStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -24,6 +25,13 @@ class ReplaceItemStatementRouteHandlerTest extends MediaWikiIntegrationTestCase use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( ReplaceStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceStatementRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceStatementRouteHandlerTest.php index 0bf6d1b1445..a04b8d4eca1 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceStatementRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/ReplaceStatementRouteHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\RestApi\RouteHandlers; +use MediaWiki\ChangeTags\ChangeTagsStore; use MediaWiki\Rest\Handler; use MediaWiki\Rest\Reporter\ErrorReporter; use MediaWiki\Rest\RequestData; @@ -23,6 +24,13 @@ class ReplaceStatementRouteHandlerTest extends MediaWikiIntegrationTestCase { use HandlerTestTrait; + protected function setUp(): void { + parent::setUp(); + $changeTagsStore = $this->createMock( ChangeTagsStore::class ); + $changeTagsStore->method( 'listExplicitlyDefinedTags' )->willReturn( [] ); + $this->setService( 'ChangeTagsStore', $changeTagsStore ); + } + public function testHandlesUnexpectedErrors(): void { $useCase = $this->createStub( ReplaceStatement::class ); $useCase->method( 'execute' )->willThrowException( new RuntimeException() ); diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/SetItemDescriptionRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/SetItemDescriptionRouteHandlerTest.php index ce91383692d..bdc73eb1ec1 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/SetItemDescriptionRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/SetItemDescriptionRouteHandlerTest.php @@ -14,6 +14,7 @@ /** * @covers \Wikibase\Repo\RestApi\RouteHandlers\SetItemDescriptionRouteHandler * @group Wikibase + * @group Database * @license GPL-2.0-or-later */ class SetItemDescriptionRouteHandlerTest extends \MediaWikiIntegrationTestCase { diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/SetItemLabelRouteHandlerTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/SetItemLabelRouteHandlerTest.php index e9757ec5672..89f931f729d 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/SetItemLabelRouteHandlerTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/SetItemLabelRouteHandlerTest.php @@ -14,6 +14,7 @@ /** * @covers \Wikibase\Repo\RestApi\RouteHandlers\SetItemLabelRouteHandler * @group Wikibase + * @group Database * @license GPL-2.0-or-later */ class SetItemLabelRouteHandlerTest extends \MediaWikiIntegrationTestCase { diff --git a/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php b/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php index 2f09086a8c7..550de675442 100644 --- a/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php +++ b/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php @@ -7,6 +7,7 @@ use ApiPageSet; use ApiQuery; use MediaWiki\Request\FauxRequest; +use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait; use MediaWikiIntegrationTestCase; use RequestContext; use Status; @@ -32,6 +33,7 @@ * @author Bene* < benestar.wikimedia@gmail.com > */ class QuerySearchEntitiesTest extends MediaWikiIntegrationTestCase { + use MockAuthorityTrait; /** * @param array $params @@ -42,6 +44,7 @@ private function getApiQuery( array $params ) { $context = new RequestContext(); $context->setLanguage( 'en-ca' ); $context->setRequest( new FauxRequest( $params, true ) ); + $context->setAuthority( $this->mockRegisteredNullAuthority() ); $main = new ApiMain( $context ); return $main->getModuleManager()->getModule( 'query' ); } diff --git a/repo/tests/phpunit/includes/Content/EntityHandlerTestCase.php b/repo/tests/phpunit/includes/Content/EntityHandlerTestCase.php index ba382f5d5e4..caa326d687e 100644 --- a/repo/tests/phpunit/includes/Content/EntityHandlerTestCase.php +++ b/repo/tests/phpunit/includes/Content/EntityHandlerTestCase.php @@ -8,7 +8,9 @@ use DataValues\Serializers\DataValueSerializer; use DummySearchIndexFieldDefinition; use InvalidArgumentException; +use LinkBatch; use LogicException; +use MediaWiki\Cache\LinkBatchFactory; use MediaWiki\MediaWikiServices; use MediaWiki\Revision\RevisionRecord; use MediaWiki\Revision\SlotRecord; @@ -17,6 +19,7 @@ use RuntimeException; use SearchEngine; use Serializers\Serializer; +use Site; use Title; use Wikibase\DataAccess\DatabaseEntitySource; use Wikibase\DataAccess\EntitySourceDefinitions; @@ -56,6 +59,7 @@ protected function setUp(): void { 'WikibaseRepo.EntityTypeDefinitions', $this->getEntityTypeDefinitions() ); + $this->setService( 'WikibaseClient.SiteGroup', Site::GROUP_NONE ); } abstract public function getModelId(); @@ -720,7 +724,13 @@ public function providePageProperties() { * @dataProvider providePageProperties */ public function testPageProperties( EntityContent $content, array $expectedProps ) { + $lb = $this->createMock( LinkBatch::class ); + $lb->method( 'doQuery' )->willReturn( false ); + $lbFactory = $this->createMock( LinkBatchFactory::class ); + $lbFactory->method( 'newLinkBatch' )->willReturn( $lb ); + $this->setService( 'LinkBatchFactory', $lbFactory ); $title = Title::makeTitle( NS_MAIN, 'Foo' ); + $title->setContentModel( CONTENT_MODEL_WIKITEXT ); $contentRenderer = $this->getServiceContainer()->getContentRenderer(); $parserOutput = $contentRenderer->getParserOutput( $content, $title, null, null, false ); diff --git a/repo/tests/phpunit/includes/Content/PropertyHandlerTest.php b/repo/tests/phpunit/includes/Content/PropertyHandlerTest.php index 3b65e735c5d..ad3c8a0532d 100644 --- a/repo/tests/phpunit/includes/Content/PropertyHandlerTest.php +++ b/repo/tests/phpunit/includes/Content/PropertyHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Repo\Tests\Content; +use MediaWiki\Page\WikiPageFactory; use ParserOutput; use Title; use Wikibase\DataModel\Entity\EntityDocument; @@ -25,6 +26,7 @@ * @group WikibaseProperty * @group WikibaseEntity * @group WikibaseEntityHandler + * @group Database * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > @@ -196,10 +198,12 @@ public function testDataForSearchIndex() { } public function testGetParserOutput() { + $this->setService( 'WikiPageFactory', $this->createMock( WikiPageFactory::class ) ); $content = $this->newEntityContent(); $contentRenderer = $this->getServiceContainer()->getContentRenderer(); $title = Title::makeTitle( NS_MAIN, 'Foo' ); + $title->setContentModel( CONTENT_MODEL_WIKITEXT ); $parserOutput = $contentRenderer->getParserOutput( $content, $title ); $expectedUsedOptions = [ 'userlang', 'wb', 'termboxVersion' ]; diff --git a/repo/tests/phpunit/includes/FederatedProperties/Hooks/HtmlPageLinkRendererEndHookHandlerTest.php b/repo/tests/phpunit/includes/FederatedProperties/Hooks/HtmlPageLinkRendererEndHookHandlerTest.php index e8ff6fd7e98..d3e454f597c 100644 --- a/repo/tests/phpunit/includes/FederatedProperties/Hooks/HtmlPageLinkRendererEndHookHandlerTest.php +++ b/repo/tests/phpunit/includes/FederatedProperties/Hooks/HtmlPageLinkRendererEndHookHandlerTest.php @@ -11,6 +11,7 @@ use Wikibase\DataModel\Entity\Property; use Wikibase\Repo\FederatedProperties\ApiRequestExecutionException; use Wikibase\Repo\Tests\Hooks\HtmlPageLinkRendererEndHookHandlerTestBase; +use Wikimedia\TestingAccessWrapper; /** * @covers \Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler @@ -28,6 +29,8 @@ public function testDoHtmlPageLinkRendererBegin( LinkRenderer $linkRenderer, Req $handler = $this->newInstance( 'foo', false, true, Property::ENTITY_TYPE ); $title = Title::makeTitle( WB_NS_PROPERTY, self::PROPERTY_WITH_LABEL ); + $wrapper = TestingAccessWrapper::newFromObject( $title ); + $wrapper->mRedirect = false; $text = $title->getFullText(); $customAttribs = []; diff --git a/repo/tests/phpunit/includes/FederatedProperties/ParserOutput/FederatedPropertiesPrefetchingEntityParserOutputGeneratorDecoratorTest.php b/repo/tests/phpunit/includes/FederatedProperties/ParserOutput/FederatedPropertiesPrefetchingEntityParserOutputGeneratorDecoratorTest.php index 665bf1919f4..bd5192832d1 100644 --- a/repo/tests/phpunit/includes/FederatedProperties/ParserOutput/FederatedPropertiesPrefetchingEntityParserOutputGeneratorDecoratorTest.php +++ b/repo/tests/phpunit/includes/FederatedProperties/ParserOutput/FederatedPropertiesPrefetchingEntityParserOutputGeneratorDecoratorTest.php @@ -3,6 +3,8 @@ declare( strict_types = 1 ); namespace Wikibase\Repo\Tests\FederatedProperties\ParserOutput; +use LinkBatch; +use MediaWiki\Cache\LinkBatchFactory; use Psr\SimpleCache\CacheInterface; use RepoGroup; use Wikibase\DataModel\Entity\EntityId; @@ -34,6 +36,12 @@ class FederatedPropertiesPrefetchingEntityParserOutputGeneratorDecoratorTest extends EntityParserOutputGeneratorTestBase { public function testShouldPrefetchFederatedProperties() { + $lb = $this->createMock( LinkBatch::class ); + $lb->method( 'doQuery' )->willReturn( false ); + $lbFactory = $this->createMock( LinkBatchFactory::class ); + $lbFactory->method( 'newLinkBatch' )->willReturn( $lb ); + $this->setService( 'LinkBatchFactory', $lbFactory ); + $labelLanguage = 'en'; $fedPropId1 = new FederatedPropertyId( 'http://wikidata.org/entity/P123', 'P123' ); diff --git a/repo/tests/phpunit/includes/Hooks/MakeGlobalVariablesScriptHookHandlerTest.php b/repo/tests/phpunit/includes/Hooks/MakeGlobalVariablesScriptHookHandlerTest.php index 599037e4aef..5e43e14f3ec 100644 --- a/repo/tests/phpunit/includes/Hooks/MakeGlobalVariablesScriptHookHandlerTest.php +++ b/repo/tests/phpunit/includes/Hooks/MakeGlobalVariablesScriptHookHandlerTest.php @@ -18,6 +18,7 @@ * @covers \Wikibase\Repo\Hooks\MakeGlobalVariablesScriptHookHandler * * @group Wikibase + * @group Database * * @license GPL-2.0-or-later */ diff --git a/repo/tests/phpunit/includes/Rdf/RdfBuilderTest.php b/repo/tests/phpunit/includes/Rdf/RdfBuilderTest.php index 15db666d008..d140b96df9e 100644 --- a/repo/tests/phpunit/includes/Rdf/RdfBuilderTest.php +++ b/repo/tests/phpunit/includes/Rdf/RdfBuilderTest.php @@ -46,6 +46,7 @@ * * @group Wikibase * @group WikibaseRdf + * @group Database * * @license GPL-2.0-or-later * @author Daniel Kinzler diff --git a/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php b/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php index 12a9bd95552..a8c341bc46f 100644 --- a/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php +++ b/repo/tests/phpunit/includes/Specials/SpecialAvailableBadgesTest.php @@ -2,6 +2,8 @@ namespace Wikibase\Repo\Tests\Specials; +use MediaWiki\Linker\LinkRenderer; +use MediaWiki\Linker\LinkRendererFactory; use SpecialPageTestBase; use Title; use Wikibase\DataAccess\PrefetchingTermLookup; @@ -51,6 +53,13 @@ protected function newSpecialPage() { } public function testExecute() { + $linkRenderer = $this->createMock( LinkRenderer::class ); + $linkRenderer->method( 'makeLink' )->willReturnCallback( static function ( $target, $text ) { + return $text ?? Title::castFromLinkTarget( $target )->getPrefixedText(); + } ); + $lrFactory = $this->createMock( LinkRendererFactory::class ); + $lrFactory->method( 'create' )->willReturn( $linkRenderer ); + $this->setService( 'LinkRendererFactory', $lrFactory ); list( $output, ) = $this->executeSpecialPage( '' ); $this->assertIsString( $output ); diff --git a/repo/tests/phpunit/maintenance/ImportFederatedPropertiesSampleDataTest.php b/repo/tests/phpunit/maintenance/ImportFederatedPropertiesSampleDataTest.php index 67d31e01820..c6aa44846a1 100644 --- a/repo/tests/phpunit/maintenance/ImportFederatedPropertiesSampleDataTest.php +++ b/repo/tests/phpunit/maintenance/ImportFederatedPropertiesSampleDataTest.php @@ -15,6 +15,7 @@ * @covers \Wikibase\Repo\Maintenance\ImportFederatedPropertiesSampleData * * @group Wikibase + * @group Database * * @license GPL-2.0-or-later */ diff --git a/repo/tests/phpunit/unit/RepoNoBadUsageTest.php b/repo/tests/phpunit/unit/RepoNoBadUsageTest.php index 8ef9d4ed7bc..aaa695c77e3 100644 --- a/repo/tests/phpunit/unit/RepoNoBadUsageTest.php +++ b/repo/tests/phpunit/unit/RepoNoBadUsageTest.php @@ -20,7 +20,9 @@ protected function getBadPatternsWithAllowedUsages(): array { 'WikibaseClient::' => [ 'includes/ChangeModification/DispatchChangesJob.php' => 1, // guarded by isClientEnabled() ], - 'WikibaseClient.' => [], + 'WikibaseClient.' => [ + 'tests/phpunit/includes/Content/EntityHandlerTestCase.php' => 1, // mock + ], 'Wikibase\\Client\\' => [ 'includes/ChangeModification/DispatchChangesJob.php' => 1, // see above ],