jenkins-bot has submitted this change and it was merged. Change subject: Use PHP 5.5's …::class feature instead of strings in client ......................................................................
Use PHP 5.5's …::class feature instead of strings in client I2c1a4d6 does the same in view. More patches to come (there are ~90 full qualified class names in strings in lib, and ~280 in repo). This is not a blind, fully automatic replacement. I reviewed every replacement. I found a mistake while doing this (see DataUpdateHookHandlersTest) and replaced SiteLinkTable mocks with the SiteLinkLookup interface when possible. Change-Id: I577208e75657864d2badb636659f87908fedf794 --- M client/tests/phpunit/includes/Api/PageTermsTest.php M client/tests/phpunit/includes/CachingOtherProjectsSitesProviderTest.php M client/tests/phpunit/includes/Changes/AffectedPagesFinderTest.php M client/tests/phpunit/includes/Changes/ChangeHandlerTest.php M client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php M client/tests/phpunit/includes/ClientParserOutputDataUpdaterTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/LanguageAwareRendererTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/VariantsAwareRendererTest.php M client/tests/phpunit/includes/DataAccess/Scribunto/EntityAccessorTest.php M client/tests/phpunit/includes/DataAccess/Scribunto/ScribuntoLuaWikibaseInProcessEntityCacheTest.php M client/tests/phpunit/includes/DataAccess/Scribunto/SnakSerializationRendererTest.php M client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php M client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaEntityBindingsTest.php M client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php M client/tests/phpunit/includes/Hooks/BaseTemplateAfterPortalHandlerTest.php M client/tests/phpunit/includes/Hooks/BeforePageDisplayHandlerTest.php M client/tests/phpunit/includes/Hooks/ChangesListSpecialPageHookHandlersTest.php M client/tests/phpunit/includes/Hooks/DataUpdateHookHandlersTest.php M client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php M client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php M client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php M client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php M client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php M client/tests/phpunit/includes/Hooks/ParserLimitHookHandlersTest.php M client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php M client/tests/phpunit/includes/Hooks/SidebarHookHandlersTest.php M client/tests/phpunit/includes/Hooks/SkinTemplateOutputPageBeforeExecHandlerTest.php M client/tests/phpunit/includes/LangLinkHandlerTest.php M client/tests/phpunit/includes/Modules/SiteModuleTest.php M client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php M client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php M client/tests/phpunit/includes/Serializer/ClientEntitySerializerTest.php M client/tests/phpunit/includes/SiteLinkCommentCreatorTest.php M client/tests/phpunit/includes/Specials/SpecialPagesWithBadgesTest.php M client/tests/phpunit/includes/Store/AddUsagesForPageJobTest.php M client/tests/phpunit/includes/Store/Sql/BulkSubscriptionUpdaterTest.php M client/tests/phpunit/includes/Store/Sql/ConsistentReadConnectionManagerTest.php M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php M client/tests/phpunit/includes/Usage/SiteLinkUsageLookupTest.php M client/tests/phpunit/includes/Usage/Sql/EntityUsageTableBuilderTest.php M client/tests/phpunit/includes/Usage/UsageTrackingSnakFormatterTest.php M client/tests/phpunit/includes/Usage/UsageTrackingTermLookupTest.php M client/tests/phpunit/includes/UsageUpdaterTest.php 46 files changed, 296 insertions(+), 190 deletions(-) Approvals: Bene: Looks good to me, approved Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/client/tests/phpunit/includes/Api/PageTermsTest.php b/client/tests/phpunit/includes/Api/PageTermsTest.php index caec3e6..575f7fe 100644 --- a/client/tests/phpunit/includes/Api/PageTermsTest.php +++ b/client/tests/phpunit/includes/Api/PageTermsTest.php @@ -3,6 +3,7 @@ namespace Wikibase\Client\Tests\Api; use ApiMain; +use ApiPageSet; use ApiQuery; use FauxRequest; use Language; @@ -48,7 +49,7 @@ $main = new ApiMain( $context ); - $pageSet = $this->getMockBuilder( 'ApiPageSet' ) + $pageSet = $this->getMockBuilder( ApiPageSet::class ) ->setConstructorArgs( array( $main ) ) ->getMock(); @@ -56,7 +57,7 @@ ->method( 'getGoodTitles' ) ->will( $this->returnValue( $titles ) ); - $query = $this->getMockBuilder( 'ApiQuery' ) + $query = $this->getMockBuilder( ApiQuery::class ) ->setConstructorArgs( array( $main, $params['action'] ) ) ->setMethods( array( 'getPageSet' ) ) ->getMock(); @@ -121,7 +122,7 @@ $termObjectsByEntityId[$key] = $this->makeTermsFromGroups( $entityId, $termGroups ); } - $termIndex = $this->getMock( 'Wikibase\TermIndex' ); + $termIndex = $this->getMock( TermIndex::class ); $termIndex->expects( $this->any() ) ->method( 'getTermsOfEntities' ) ->will( $this->returnCallback( @@ -212,7 +213,7 @@ * @return EntityIdLookup */ private function getEntityIdLookup( array $entityIds ) { - $idLookup = $this->getMock( 'Wikibase\Store\EntityIdLookup' ); + $idLookup = $this->getMock( EntityIdLookup::class ); $idLookup->expects( $this->any() ) ->method( 'getEntityIds' ) ->will( $this->returnValue( $entityIds ) ); diff --git a/client/tests/phpunit/includes/CachingOtherProjectsSitesProviderTest.php b/client/tests/phpunit/includes/CachingOtherProjectsSitesProviderTest.php index 8287163b..a787202 100644 --- a/client/tests/phpunit/includes/CachingOtherProjectsSitesProviderTest.php +++ b/client/tests/phpunit/includes/CachingOtherProjectsSitesProviderTest.php @@ -24,7 +24,7 @@ * @return OtherProjectsSitesProvider */ private function getOtherProjectsSitesProvider() { - $otherProjectsSitesProvider = $this->getMock( 'Wikibase\Client\OtherProjectsSitesProvider' ); + $otherProjectsSitesProvider = $this->getMock( OtherProjectsSitesProvider::class ); $otherProjectsSitesProvider->expects( $this->once() ) ->method( 'getOtherProjectsSiteIds' ) diff --git a/client/tests/phpunit/includes/Changes/AffectedPagesFinderTest.php b/client/tests/phpunit/includes/Changes/AffectedPagesFinderTest.php index 86f8b94..98f4768 100644 --- a/client/tests/phpunit/includes/Changes/AffectedPagesFinderTest.php +++ b/client/tests/phpunit/includes/Changes/AffectedPagesFinderTest.php @@ -12,11 +12,13 @@ use Wikibase\Client\Usage\EntityUsage; use Wikibase\Client\Usage\PageEntityUsages; use Wikibase\Client\Usage\SiteLinkUsageLookup; +use Wikibase\Client\Usage\UsageLookup; use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\ItemChange; +use Wikibase\Lib\Store\SiteLinkLookup; use Wikibase\Lib\Store\StorageException; use Wikibase\Test\TestChanges; @@ -41,7 +43,7 @@ * @return TitleFactory */ private function getTitleFactory() { - $titleFactory = $this->getMock( 'Wikibase\Client\Store\TitleFactory' ); + $titleFactory = $this->getMock( TitleFactory::class ); $titleFactory->expects( $this->any() ) ->method( 'newFromID' ) @@ -68,7 +70,7 @@ } private function getAffectedPagesFinder( array $usage, array $expectedAspects = array() ) { - $usageLookup = $this->getMock( 'Wikibase\Client\Usage\UsageLookup' ); + $usageLookup = $this->getMock( UsageLookup::class ); $usageLookup->expects( $this->any() ) ->method( 'getPagesUsing' ) @@ -480,7 +482,7 @@ } private function getSiteLinkUsageLookup( $pageTitle ) { - $siteLinkLookup = $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ); + $siteLinkLookup = $this->getMock( SiteLinkLookup::class ); $siteLinkLookup->expects( $this->any() ) ->method( 'getItemIdForLink' ) diff --git a/client/tests/phpunit/includes/Changes/ChangeHandlerTest.php b/client/tests/phpunit/includes/Changes/ChangeHandlerTest.php index b3fbcc1..b156846 100644 --- a/client/tests/phpunit/includes/Changes/ChangeHandlerTest.php +++ b/client/tests/phpunit/includes/Changes/ChangeHandlerTest.php @@ -4,10 +4,12 @@ use ArrayIterator; use MediaWikiTestCase; +use SiteStore; use Title; use Wikibase\Change; use Wikibase\Client\Changes\AffectedPagesFinder; use Wikibase\Client\Changes\ChangeHandler; +use Wikibase\Client\Changes\ChangeListTransformer; use Wikibase\Client\Changes\PageUpdater; use Wikibase\Client\Store\TitleFactory; use Wikibase\Client\Usage\EntityUsage; @@ -48,8 +50,11 @@ ); } + /** + * @return ChangeListTransformer + */ private function getChangeListTransformer() { - $transformer = $this->getMock( 'Wikibase\Client\Changes\ChangeListTransformer' ); + $transformer = $this->getMock( ChangeListTransformer::class ); $transformer->expects( $this->any() ) ->method( 'transformChangeList' ) @@ -73,7 +78,7 @@ $titleFactory, $updater ?: new MockPageUpdater(), $changeListTransformer, - $this->getMock( 'SiteStore' ), + $this->getMock( SiteStore::class ), 'repowiki', true ); @@ -282,7 +287,7 @@ $titlesById = $this->getFakePageIdMap( $pageNamesPerItemId ); $pageIdsByTitle = array_flip( $titlesById ); - $titleFactory = $this->getMock( 'Wikibase\Client\Store\TitleFactory' ); + $titleFactory = $this->getMock( TitleFactory::class ); $titleFactory->expects( $this->any() ) ->method( 'newFromID' ) @@ -324,7 +329,7 @@ * @return UsageLookup */ private function getUsageLookup( SiteLinkLookup $siteLinkLookup ) { - $usageLookup = $this->getMock( 'Wikibase\Client\Usage\UsageLookup' ); + $usageLookup = $this->getMock( UsageLookup::class ); $usageLookup->expects( $this->any() ) ->method( 'getPagesUsing' ) ->will( $this->returnCallback( diff --git a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php index f3edfdc..f19201c 100644 --- a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php +++ b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php @@ -32,7 +32,7 @@ * @return JobQueueGroup */ private function getJobQueueGroupMock() { - $jobQueueGroup = $this->getMockBuilder( 'JobQueueGroup' ) + $jobQueueGroup = $this->getMockBuilder( JobQueueGroup::class ) ->disableOriginalConstructor() ->getMock(); @@ -43,7 +43,7 @@ * @return RecentChangeFactory */ private function getRCFactoryMock() { - $rcFactory = $this->getMockBuilder( 'Wikibase\Client\RecentChanges\RecentChangeFactory' ) + $rcFactory = $this->getMockBuilder( RecentChangeFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -58,7 +58,7 @@ * @return RecentChangesDuplicateDetector */ private function getRCDupeDetectorMock() { - $rcDupeDetector = $this->getMockBuilder( 'Wikibase\Client\RecentChanges\RecentChangesDuplicateDetector' ) + $rcDupeDetector = $this->getMockBuilder( RecentChangesDuplicateDetector::class ) ->disableOriginalConstructor() ->getMock(); @@ -71,7 +71,7 @@ * @return Title */ private function getTitleMock( $text ) { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -94,7 +94,7 @@ * @return EntityChange */ private function getEntityChangeMock() { - $change = $this->getMockBuilder( 'Wikibase\EntityChange' ) + $change = $this->getMockBuilder( EntityChange::class ) ->disableOriginalConstructor() ->getMock(); @@ -105,7 +105,7 @@ * @return RecentChange */ private function getRecentChangeMock() { - $change = $this->getMockBuilder( 'RecentChange' ) + $change = $this->getMockBuilder( RecentChange::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/ClientParserOutputDataUpdaterTest.php b/client/tests/phpunit/includes/ClientParserOutputDataUpdaterTest.php index 3553609..9fe9fde 100644 --- a/client/tests/phpunit/includes/ClientParserOutputDataUpdaterTest.php +++ b/client/tests/phpunit/includes/ClientParserOutputDataUpdaterTest.php @@ -86,19 +86,17 @@ * @return OtherProjectsSidebarGeneratorFactory */ private function getOtherProjectsSidebarGeneratorFactory( array $otherProjects ) { - $otherProjectsSidebarGenerator = $this->getOtherProjectsSidebarGenerator( $otherProjects ); + $generator = $this->getOtherProjectsSidebarGenerator( $otherProjects ); - $otherProjectsSidebarGeneratorFactory = $this->getMockBuilder( - 'Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory' - ) + $factory = $this->getMockBuilder( OtherProjectsSidebarGeneratorFactory::class ) ->disableOriginalConstructor() ->getMock(); - $otherProjectsSidebarGeneratorFactory->expects( $this->any() ) + $factory->expects( $this->any() ) ->method( 'getOtherProjectsSidebarGenerator' ) - ->will( $this->returnValue( $otherProjectsSidebarGenerator ) ); + ->will( $this->returnValue( $generator ) ); - return $otherProjectsSidebarGeneratorFactory; + return $factory; } /** @@ -107,15 +105,15 @@ * @return OtherProjectsSidebarGenerator */ private function getOtherProjectsSidebarGenerator( array $otherProjects ) { - $otherProjectsSidebarGenerator = $this->getMockBuilder( 'Wikibase\Client\Hooks\OtherProjectsSidebarGenerator' ) + $generator = $this->getMockBuilder( OtherProjectsSidebarGenerator::class ) ->disableOriginalConstructor() ->getMock(); - $otherProjectsSidebarGenerator->expects( $this->any() ) + $generator->expects( $this->any() ) ->method( 'buildProjectLinkSidebar' ) ->will( $this->returnValue( $otherProjects ) ); - return $otherProjectsSidebarGenerator; + return $generator; } public function testUpdateItemIdProperty() { diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/LanguageAwareRendererTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/LanguageAwareRendererTest.php index 40526f1..e0469a3 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/LanguageAwareRendererTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/LanguageAwareRendererTest.php @@ -16,6 +16,7 @@ use Wikibase\DataModel\Services\Lookup\EntityLookup; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Snak\Snak; +use Wikibase\DataModel\Statement\StatementListProvider; use Wikibase\Lib\SnakFormatter; /** @@ -131,9 +132,7 @@ * @return SnaksFinder */ private function getSnaksFinder( array $snaks ) { - $snaksFinder = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\SnaksFinder' - ) + $snaksFinder = $this->getMockBuilder( SnaksFinder::class ) ->disableOriginalConstructor() ->getMock(); @@ -144,10 +143,11 @@ return $snaksFinder; } + /** + * @return PropertyIdResolver + */ private function getPropertyIdResolver() { - $propertyIdResolver = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyIdResolver' - ) + $propertyIdResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); @@ -158,10 +158,11 @@ return $propertyIdResolver; } + /** + * @return PropertyIdResolver + */ private function getPropertyIdResolverForPropertyNotFound() { - $propertyIdResolver = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyIdResolver' - ) + $propertyIdResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); @@ -181,12 +182,10 @@ * @return EntityLookup */ private function getEntityLookup( $entityAccessLimit ) { - $lookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\EntityLookup' ); + $lookup = $this->getMock( EntityLookup::class ); $lookup->expects( $this->any() ) ->method( 'getEntity' ) - ->will( $this->returnValue( - $this->getMock( 'Wikibase\DataModel\StatementListProvider' ) - ) ); + ->will( $this->returnValue( $this->getMock( StatementListProvider::class ) ) ); return new RestrictedEntityLookup( $lookup, $entityAccessLimit ); } @@ -195,7 +194,7 @@ * @return SnakFormatter */ private function getSnakFormatter() { - $snakFormatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' ); + $snakFormatter = $this->getMock( SnakFormatter::class ); $snakFormatter->expects( $this->any() ) ->method( 'formatSnak' ) diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php index 4a0efbb..8a69602 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php @@ -6,15 +6,22 @@ use ParserOptions; use ParserOutput; use PHPUnit_Framework_TestCase; +use PPFrame; use PPFrame_Hash; +use PPNode; use Preprocessor_Hash; use Title; use Wikibase\Client\DataAccess\PropertyParserFunction\Runner; +use Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRenderer; +use Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory; +use Wikibase\DataModel\Entity\EntityId; +use Wikibase\DataModel\Services\Lookup\EntityLookup; use Wikibase\DataModel\Services\Lookup\RestrictedEntityLookup; use Wikibase\Client\Usage\EntityUsage; use Wikibase\Client\Usage\ParserOutputUsageAccumulator; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\BasicEntityIdParser; +use Wikibase\Lib\Store\SiteLinkLookup; /** * @covers Wikibase\Client\DataAccess\PropertyParserFunction\Runner @@ -62,7 +69,7 @@ $runner = new Runner( $this->getStatementGroupRendererFactory( $itemId, 'Cat' ), - $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ), + $this->getMock( SiteLinkLookup::class ), new BasicEntityIdParser(), $this->getRestrictedEntityLookup(), 'enwiki', @@ -72,7 +79,11 @@ $parser = $this->getParser(); $frame = $this->getFromFrame( $itemId->getSerialization() ); - $result = $runner->runPropertyParserFunction( $parser, $frame, array( 'Cat', $this->getMock( 'PPNode' ) ) ); + $result = $runner->runPropertyParserFunction( + $parser, + $frame, + array( 'Cat', $this->getMock( PPNode::class ) ) + ); $expected = array( 'meow!', @@ -94,7 +105,7 @@ $runner = new Runner( $this->getStatementGroupRendererFactory( $itemId, 'Cat' ), - $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ), + $this->getMock( SiteLinkLookup::class ), new BasicEntityIdParser(), $restrictedEntityLookup, 'enwiki', @@ -103,22 +114,24 @@ $parser = $this->getParser(); $frame = $this->getFromFrame( $itemId->getSerialization() ); - $runner->runPropertyParserFunction( $parser, $frame, array( 'Cat', $this->getMock( 'PPNode' ) ) ); + $runner->runPropertyParserFunction( + $parser, + $frame, + array( 'Cat', $this->getMock( PPNode::class ) ) + ); // Still 0 as the entity has been loaded before $this->assertSame( 0, $parser->mExpensiveFunctionCount ); } public function testRunPropertyParserFunction_arbitraryAccessNotFound() { - $rendererFactory = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory' - ) + $rendererFactory = $this->getMockBuilder( StatementGroupRendererFactory::class ) ->disableOriginalConstructor() ->getMock(); $runner = new Runner( $rendererFactory, - $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ), + $this->getMock( SiteLinkLookup::class ), new BasicEntityIdParser(), $this->getRestrictedEntityLookup(), 'enwiki', @@ -128,7 +141,11 @@ $parser = $this->getParser(); $frame = $this->getFromFrame( 'ThisIsNotQuiteAnEntityId' ); - $result = $runner->runPropertyParserFunction( $parser, $frame, array( 'Cat', $this->getMock( 'PPNode' ) ) ); + $result = $runner->runPropertyParserFunction( + $parser, + $frame, + array( 'Cat', $this->getMock( PPNode::class ) ) + ); $expected = array( '', @@ -160,14 +177,11 @@ * @return RestrictedEntityLookup */ private function getRestrictedEntityLookup() { - return new RestrictedEntityLookup( - $this->getMock( 'Wikibase\DataModel\Services\Lookup\EntityLookup' ), - 200 - ); + return new RestrictedEntityLookup( $this->getMock( EntityLookup::class ), 200 ); } private function getSiteLinkLookup( ItemId $itemId ) { - $siteLinkLookup = $this->getMockBuilder( 'Wikibase\Lib\Store\SiteLinkLookup' ) + $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class ) ->getMock(); $siteLinkLookup->expects( $this->once() ) @@ -177,15 +191,20 @@ return $siteLinkLookup; } + /** + * @param string $itemIdSerialization + * + * @return PPFrame + */ private function getFromFrame( $itemIdSerialization ) { - $frame = $this->getMockBuilder( 'PPFrame' ) + $frame = $this->getMockBuilder( PPFrame::class ) ->getMock(); $frame->expects( $this->once() ) ->method( 'expand' ) ->with( 'Cat' ) ->will( $this->returnValue( 'Cat' ) ); - $childFrame = $this->getMockBuilder( 'PPFrame' ) + $childFrame = $this->getMockBuilder( PPFrame::class ) ->getMock(); $childFrame->expects( $this->once() ) ->method( 'getArgument' ) @@ -199,12 +218,16 @@ return $frame; } - private function getStatementGroupRendererFactory( $entityId, $propertyLabelOrId ) { + /** + * @param EntityId $entityId + * @param string $propertyLabelOrId + * + * @return StatementGroupRendererFactory + */ + private function getStatementGroupRendererFactory( EntityId $entityId, $propertyLabelOrId ) { $renderer = $this->getRenderer( $entityId, $propertyLabelOrId ); - $rendererFactory = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory' - ) + $rendererFactory = $this->getMockBuilder( StatementGroupRendererFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -215,10 +238,14 @@ return $rendererFactory; } - private function getRenderer( $entityId, $propertyLabelOrId ) { - $renderer = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRenderer' - ) + /** + * @param EntityId $entityId + * @param string $propertyLabelOrId + * + * @return StatementGroupRenderer + */ + private function getRenderer( EntityId $entityId, $propertyLabelOrId ) { + $renderer = $this->getMockBuilder( StatementGroupRenderer::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php index 132b11b..07b0033 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php @@ -9,6 +9,7 @@ use User; use ValueFormatters\FormatterOptions; use ValueFormatters\ValueFormatter; +use Wikibase\Client\DataAccess\PropertyIdResolver; use Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory; use Wikibase\Client\DataAccess\SnaksFinder; use Wikibase\Client\Usage\ParserOutputUsageAccumulator; @@ -17,9 +18,12 @@ use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Services\Lookup\EntityLookup; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Statement\StatementListProvider; use Wikibase\LanguageFallbackChainFactory; +use Wikibase\Lib\OutputFormatSnakFormatterFactory; +use Wikibase\Lib\SnakFormatter; /** * @covers Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory @@ -142,11 +146,11 @@ * @dataProvider allowDataAccessInUserLanguageProvider */ public function testNewRendererFromParser_languageOption( $allowDataAccessInUserLanguage ) { - $idResolver = $this->getMockBuilder( 'Wikibase\Client\DataAccess\PropertyIdResolver' ) + $idResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); - $formatterFactory = $this->getMockBuilder( 'Wikibase\Lib\OutputFormatSnakFormatterFactory' ) + $formatterFactory = $this->getMockBuilder( OutputFormatSnakFormatterFactory::class ) ->disableOriginalConstructor() ->getMock(); $formatterFactory->expects( $this->once() ) @@ -157,7 +161,7 @@ $allowDataAccessInUserLanguage ? 'es' : 'de', $options->getOption( ValueFormatter::OPT_LANG ) ); - return $this->getMock( 'Wikibase\Lib\SnakFormatter' ); + return $this->getMock( SnakFormatter::class ); } ) ); @@ -166,7 +170,7 @@ new SnaksFinder(), new LanguageFallbackChainFactory(), $formatterFactory, - $this->getMock( 'Wikibase\DataModel\Services\Lookup\EntityLookup' ), + $this->getMock( EntityLookup::class ), $allowDataAccessInUserLanguage ); $factory->newRendererFromParser( $this->getParser( 'de', 'es' ) ); @@ -190,10 +194,11 @@ ); } + /** + * @return PropertyIdResolver + */ private function getPropertyIdResolver() { - $propertyIdResolver = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyIdResolver' - ) + $propertyIdResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); @@ -206,8 +211,11 @@ return $propertyIdResolver; } + /** + * @return SnaksFinder + */ private function getSnaksFinder() { - $snakListFinder = $this->getMock( 'Wikibase\Client\DataAccess\SnaksFinder' ); + $snakListFinder = $this->getMock( SnaksFinder::class ); $snakListFinder->expects( $this->any() ) ->method( 'findSnaks' ) @@ -228,8 +236,11 @@ return new LanguageFallbackChainFactory(); } + /** + * @return SnakFormatter + */ private function getSnakFormatterFactory() { - $snakFormatter = $this->getMockBuilder( 'Wikibase\Lib\SnakFormatter' ) + $snakFormatter = $this->getMockBuilder( SnakFormatter::class ) ->disableOriginalConstructor() ->getMock(); @@ -237,9 +248,7 @@ ->method( 'formatSnak' ) ->will( $this->returnValue( 'Kittens!' ) ); - $snakFormatterFactory = $this->getMockBuilder( - 'Wikibase\Lib\OutputFormatSnakFormatterFactory' - ) + $snakFormatterFactory = $this->getMockBuilder( OutputFormatSnakFormatterFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -250,8 +259,11 @@ return $snakFormatterFactory; } + /** + * @return EntityLookup + */ private function getEntityLookup() { - $entityLookup = $this->getMockBuilder( 'Wikibase\DataModel\Services\Lookup\EntityLookup' ) + $entityLookup = $this->getMockBuilder( EntityLookup::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/VariantsAwareRendererTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/VariantsAwareRendererTest.php index 8e13480..09e20c4 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/VariantsAwareRendererTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/VariantsAwareRendererTest.php @@ -2,6 +2,8 @@ namespace Wikibase\Client\Tests\DataAccess\PropertyParserFunction; +use Wikibase\Client\DataAccess\PropertyParserFunction\LanguageAwareRenderer; +use Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory; use Wikibase\Client\DataAccess\PropertyParserFunction\VariantsAwareRenderer; use Wikibase\DataModel\Entity\ItemId; @@ -23,9 +25,7 @@ public function testRender( $expected, $itemId, $variants, $propertyLabel ) { $languageRenderer = $this->getLanguageAwareRenderer(); - $rendererFactory = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyParserFunction\StatementGroupRendererFactory' - ) + $rendererFactory = $this->getMockBuilder( StatementGroupRendererFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -74,10 +74,11 @@ ); } + /** + * @return LanguageAwareRenderer + */ private function getLanguageAwareRenderer() { - $languageRenderer = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyParserFunction\LanguageAwareRenderer' - ) + $languageRenderer = $this->getMockBuilder( LanguageAwareRenderer::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/EntityAccessorTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/EntityAccessorTest.php index 5a6f5ed..02d5991 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/EntityAccessorTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/EntityAccessorTest.php @@ -15,6 +15,7 @@ use Wikibase\DataModel\ReferenceList; use Wikibase\DataModel\Entity\BasicEntityIdParser; use Wikibase\DataModel\Services\Lookup\EntityLookup; +use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup; use Wikibase\DataModel\Snak\PropertySomeValueSnak; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Snak\SnakList; @@ -50,7 +51,7 @@ ) { $language = new Language( $langCode ); - $propertyDataTypeLookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup' ); + $propertyDataTypeLookup = $this->getMock( PropertyDataTypeLookup::class ); $propertyDataTypeLookup->expects( $this->any() ) ->method( 'getDataTypeIdForProperty' ) ->will( $this->returnValue( 'structured-cat' ) ); diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/ScribuntoLuaWikibaseInProcessEntityCacheTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/ScribuntoLuaWikibaseInProcessEntityCacheTest.php index 24126a7..292b78e 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/ScribuntoLuaWikibaseInProcessEntityCacheTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/ScribuntoLuaWikibaseInProcessEntityCacheTest.php @@ -35,7 +35,7 @@ protected static function getEntityLookup() { $phpunit = new self(); - $entityLookup = $phpunit->getMock( 'Wikibase\DataModel\Services\Lookup\EntityLookup' ); + $entityLookup = $phpunit->getMock( EntityLookup::class ); $entityLookup->expects( $phpunit->exactly( 20 ) ) ->method( 'getEntity' ) ->will( $phpunit->returnCallback( diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/SnakSerializationRendererTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/SnakSerializationRendererTest.php index 2f4b4ca..cd49ba3 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/SnakSerializationRendererTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/SnakSerializationRendererTest.php @@ -13,6 +13,7 @@ use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Serializers\SnakSerializer; use Wikibase\DataModel\Snak\PropertyValueSnak; +use Wikibase\Lib\SnakFormatter; /** * @covers Wikibase\Client\DataAccess\Scribunto\SnakSerializationRenderer @@ -49,7 +50,7 @@ private function getSnakRenderer() { $wikibaseClient = WikibaseClient::getDefaultInstance(); - $snakFormatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' ); + $snakFormatter = $this->getMock( SnakFormatter::class ); $snakFormatter->expects( $this->any() ) ->method( 'formatSnak' ) ->will( $this->returnCallback( function ( PropertyValueSnak $snak ) { diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php index 3790993..e2a6f02 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php @@ -11,6 +11,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\BasicEntityIdParser; use Wikibase\DataModel\Services\Lookup\EntityLookup; +use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup; use Wikibase\DataModel\Term\Term; use Wikibase\Lib\Store\HashSiteLinkStore; use Wikibase\Lib\Store\SiteLinkLookup; @@ -54,7 +55,7 @@ SiteLinkLookup $siteLinkLookup, UsageAccumulator $usageAccumulator = null ) { - $labelDescriptionLookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' ); + $labelDescriptionLookup = $this->getMock( LabelDescriptionLookup::class ); $labelDescriptionLookup->expects( $this->any() ) ->method( 'getLabel' ) ->will( $this->returnValue( new Term( 'xy', 'LabelString' ) ) ); diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaEntityBindingsTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaEntityBindingsTest.php index 8b239a5..3c43d19 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaEntityBindingsTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaEntityBindingsTest.php @@ -3,6 +3,7 @@ namespace Wikibase\Client\Tests\DataAccess\Scribunto; use Wikibase\Client\DataAccess\Scribunto\WikibaseLuaEntityBindings; +use Wikibase\Client\DataAccess\StatementTransclusionInteractor; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\BasicEntityIdParser; use Wikibase\DataModel\Statement\Statement; @@ -23,7 +24,7 @@ * @return WikibaseLuaEntityBindings */ private function getWikibaseLuaEntityBindings() { - $entityStatementsRenderer = $this->getMockBuilder( 'Wikibase\Client\DataAccess\StatementTransclusionInteractor' ) + $entityStatementsRenderer = $this->getMockBuilder( StatementTransclusionInteractor::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php b/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php index 018e0aa..3fc331d 100644 --- a/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php +++ b/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php @@ -18,6 +18,7 @@ use Wikibase\DataModel\Snak\Snak; use Wikibase\EntityRevision; use Wikibase\Lib\SnakFormatter; +use Wikibase\Lib\Store\EntityRevisionLookup; use Wikibase\Lib\Store\RevisionBasedEntityLookup; use Wikibase\Lib\Store\RevisionedUnresolvedRedirectException; @@ -109,9 +110,7 @@ * @return SnaksFinder */ private function getSnaksFinder( array $snaks ) { - $snaksFinder = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\SnaksFinder' - ) + $snaksFinder = $this->getMockBuilder( SnaksFinder::class ) ->disableOriginalConstructor() ->getMock(); @@ -122,10 +121,11 @@ return $snaksFinder; } + /** + * @return PropertyIdResolver + */ private function getPropertyIdResolver() { - $propertyIdResolver = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyIdResolver' - ) + $propertyIdResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); @@ -136,10 +136,11 @@ return $propertyIdResolver; } + /** + * @return PropertyIdResolver + */ private function getPropertyIdResolverForPropertyNotFound() { - $propertyIdResolver = $this->getMockBuilder( - 'Wikibase\Client\DataAccess\PropertyIdResolver' - ) + $propertyIdResolver = $this->getMockBuilder( PropertyIdResolver::class ) ->disableOriginalConstructor() ->getMock(); @@ -157,8 +158,11 @@ return new RevisionBasedEntityLookup( $this->getEntityRevisionLookup() ); } + /** + * @return EntityRevisionLookup + */ private function getEntityRevisionLookup() { - $lookup = $this->getMock( 'Wikibase\Lib\Store\EntityRevisionLookup' ); + $lookup = $this->getMock( EntityRevisionLookup::class ); $lookup->expects( $this->any() ) ->method( 'getEntityRevision' ) @@ -186,7 +190,7 @@ * @return SnakFormatter */ private function getSnakFormatter() { - $snakFormatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' ); + $snakFormatter = $this->getMock( SnakFormatter::class ); $snakFormatter->expects( $this->any() ) ->method( 'formatSnak' ) diff --git a/client/tests/phpunit/includes/Hooks/BaseTemplateAfterPortalHandlerTest.php b/client/tests/phpunit/includes/Hooks/BaseTemplateAfterPortalHandlerTest.php index 717a546..0b9df6b 100644 --- a/client/tests/phpunit/includes/Hooks/BaseTemplateAfterPortalHandlerTest.php +++ b/client/tests/phpunit/includes/Hooks/BaseTemplateAfterPortalHandlerTest.php @@ -2,6 +2,7 @@ namespace Wikibase\Client\Tests\Hooks; +use BaseTemplate; use Wikibase\Client\Hooks\BaseTemplateAfterPortletHandler; /** @@ -21,7 +22,7 @@ * @dataProvider getEditLinkProvider */ public function testGetEditLink( $expect, $link, $name ) { - $template = $this->getMockBuilder( 'BaseTemplate' ) + $template = $this->getMockBuilder( BaseTemplate::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/BeforePageDisplayHandlerTest.php b/client/tests/phpunit/includes/Hooks/BeforePageDisplayHandlerTest.php index 96e025b..5fdd6da 100644 --- a/client/tests/phpunit/includes/Hooks/BeforePageDisplayHandlerTest.php +++ b/client/tests/phpunit/includes/Hooks/BeforePageDisplayHandlerTest.php @@ -5,7 +5,10 @@ use RequestContext; use Skin; use SkinFallback; +use Title; +use User; use Wikibase\Client\Hooks\BeforePageDisplayHandler; +use Wikibase\NamespaceChecker; /** * @covers Wikibase\Client\Hooks\BeforePageDisplayHandler @@ -239,8 +242,13 @@ return $context; } + /** + * @param bool $titleExists + * + * @return Title + */ private function getTitle( $titleExists ) { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -251,8 +259,13 @@ return $title; } + /** + * @param bool $loggedIn + * + * @return User + */ private function getUser( $loggedIn ) { - $user = $this->getMockBuilder( 'User' ) + $user = $this->getMockBuilder( User::class ) ->disableOriginalConstructor() ->getMock(); @@ -263,8 +276,13 @@ return $user; } + /** + * @param bool $wikibaseEnabled + * + * @return NamespaceChecker + */ private function getNamespaceChecker( $wikibaseEnabled ) { - $namespaceChecker = $this->getMockBuilder( 'Wikibase\NamespaceChecker' ) + $namespaceChecker = $this->getMockBuilder( NamespaceChecker::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/ChangesListSpecialPageHookHandlersTest.php b/client/tests/phpunit/includes/Hooks/ChangesListSpecialPageHookHandlersTest.php index 0a2556c..77b2aef 100644 --- a/client/tests/phpunit/includes/Hooks/ChangesListSpecialPageHookHandlersTest.php +++ b/client/tests/phpunit/includes/Hooks/ChangesListSpecialPageHookHandlersTest.php @@ -4,7 +4,10 @@ use FauxRequest; use FormOptions; +use IDatabase; +use LoadBalancer; use SpecialPageFactory; +use User; use Wikibase\Client\Hooks\ChangesListSpecialPageHookHandlers; /** @@ -369,8 +372,13 @@ return new FauxRequest( $requestParams ); } + /** + * @param array $userOptions + * + * @return User + */ private function getUser( array $userOptions ) { - $user = $this->getMockBuilder( 'User' ) + $user = $this->getMockBuilder( User::class ) ->disableOriginalConstructor() ->getMock(); @@ -389,8 +397,11 @@ return $user; } + /** + * @return LoadBalancer + */ private function getLoadBalancer() { - $databaseBase = $this->getMockBuilder( 'IDatabase' ) + $databaseBase = $this->getMockBuilder( IDatabase::class ) ->disableOriginalConstructor() ->getMock(); @@ -400,7 +411,7 @@ return "'$input'"; } ) ); - $loadBalancer = $this->getMockBuilder( 'LoadBalancer' ) + $loadBalancer = $this->getMockBuilder( LoadBalancer::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/DataUpdateHookHandlersTest.php b/client/tests/phpunit/includes/Hooks/DataUpdateHookHandlersTest.php index ced5e77..2e9c150 100644 --- a/client/tests/phpunit/includes/Hooks/DataUpdateHookHandlersTest.php +++ b/client/tests/phpunit/includes/Hooks/DataUpdateHookHandlersTest.php @@ -3,6 +3,7 @@ namespace Wikibase\Client\Tests\Hooks; use JobQueueGroup; +use LinksUpdate; use ParserOutput; use Title; use Wikibase\Client\Hooks\DataUpdateHookHandlers; @@ -10,7 +11,6 @@ use Wikibase\Client\Usage\EntityUsage; use Wikibase\Client\Usage\ParserOutputUsageAccumulator; use Wikibase\DataModel\Entity\ItemId; -use WikiPage; /** * @covers Wikibase\Client\Hooks\DataUpdateHookHandlers @@ -41,7 +41,7 @@ $prune = true, $add = true ) { - $usageUpdater = $this->getMockBuilder( 'Wikibase\Client\Store\UsageUpdater' ) + $usageUpdater = $this->getMockBuilder( UsageUpdater::class ) ->disableOriginalConstructor() ->getMock(); @@ -90,7 +90,7 @@ $touched = null, $useJobQueue = false ) { - $jobScheduler = $this->getMockBuilder( 'JobQueueGroup' ) + $jobScheduler = $this->getMockBuilder( JobQueueGroup::class ) ->disableOriginalConstructor() ->getMock(); @@ -193,7 +193,7 @@ * @return Title */ private function newTitle( $id, $ns, $text, $touched ) { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -221,12 +221,12 @@ * @param EntityUsage[]|null $usages * @param string $touched * - * @return WikiPage + * @return LinksUpdate */ private function newLinksUpdate( Title $title, array $usages = null, $touched ) { $pout = $this->newParserOutput( $usages, $touched ); - $linksUpdate = $this->getMockBuilder( 'LinksUpdate' ) + $linksUpdate = $this->getMockBuilder( LinksUpdate::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php b/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php index c8e73c7..c6c9d25 100644 --- a/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php +++ b/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php @@ -7,6 +7,7 @@ use Wikibase\Client\Hooks\DeletePageNoticeCreator; use Wikibase\Client\RepoLinker; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\Lib\Store\SiteLinkLookup; /** * @covers Wikibase\Client\Hooks\DeletePageNoticeCreator @@ -44,11 +45,7 @@ * @dataProvider getPageDeleteNoticeHtmlProvider */ public function testGetPageDeleteNoticeHtml( $expected, Title $title, $message ) { - $siteLinkLookup = $this->getMock( - 'Wikibase\Lib\Store\SiteLinkTable', - array( 'getItemIdForSiteLink' ), - array( 'SiteLinkTable', true ) - ); + $siteLinkLookup = $this->getMock( SiteLinkLookup::class ); $siteLinkLookup->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) diff --git a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php index a73956f..03fe883 100644 --- a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php +++ b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php @@ -4,8 +4,12 @@ use IContextSource; use RequestContext; +use Title; use Wikibase\Client\Hooks\InfoActionHookHandler; +use Wikibase\Client\RepoLinker; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\Lib\Store\SiteLinkLookup; +use Wikibase\NamespaceChecker; /** * @covers Wikibase\Client\Hooks\InfoActionHookHandler @@ -79,7 +83,7 @@ * @return InfoActionHookHandler */ private function newHookHandler( $enabled, $entityId ) { - $namespaceChecker = $this->getMockBuilder( 'Wikibase\NamespaceChecker' ) + $namespaceChecker = $this->getMockBuilder( NamespaceChecker::class ) ->disableOriginalConstructor() ->getMock(); @@ -87,7 +91,7 @@ ->method( 'isWikibaseEnabled' ) ->will( $this->returnValue( $enabled ) ); - $repoLinker = $this->getMockBuilder( 'Wikibase\Client\RepoLinker' ) + $repoLinker = $this->getMockBuilder( RepoLinker::class ) ->disableOriginalConstructor() ->getMock(); @@ -95,7 +99,7 @@ ->method( 'buildEntityLink' ) ->will( $this->returnValue( 'https://www.wikidata.org/wiki/Q4' ) ); - $siteLinkLookup = $this->getMockBuilder( 'Wikibase\Lib\Store\SiteLinkTable' ) + $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class ) ->disableOriginalConstructor() ->getMock(); @@ -117,7 +121,7 @@ * @return IContextSource */ private function getContext() { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php index 0e4306e..979457a 100644 --- a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php +++ b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php @@ -11,6 +11,7 @@ use Wikibase\Client\Hooks\LanguageLinkBadgeDisplay; use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup; use Wikibase\DataModel\SiteLink; use Wikibase\DataModel\Term\Term; @@ -31,9 +32,7 @@ * @return LanguageLinkBadgeDisplay */ private function getLanguageLinkBadgeDisplay() { - $labelLookup = $this->getMockBuilder( - 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' - ) + $labelLookup = $this->getMockBuilder( LabelDescriptionLookup::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php b/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php index 7e84ed6..7baea7a 100644 --- a/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php +++ b/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php @@ -3,11 +3,14 @@ namespace Wikibase\Client\Tests\Hooks; use Language; +use MovePageForm; +use OutputPage; use Title; use Wikibase\Client\Hooks\MovePageNotice; use Wikibase\Client\RepoLinker; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\SiteLink; +use Wikibase\Lib\Store\SiteLinkLookup; /** * @covers Wikibase\Client\Hooks\MovePageNotice @@ -46,11 +49,7 @@ * @dataProvider getMovePageNoticeCaseProvider */ public function testDoSpecialMovepageAfterMove( $expected, Title $oldTitle, Title $newTitle ) { - $siteLinkLookup = $this->getMock( - 'Wikibase\Lib\Store\SiteLinkTable', - array( 'getItemIdForSiteLink' ), - array( 'SiteLinkTable', true ) - ); + $siteLinkLookup = $this->getMock( SiteLinkLookup::class ); $siteLinkLookup->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) @@ -63,7 +62,7 @@ $this->getRepoLinker() ); - $outputPage = $this->getMockBuilder( 'OutputPage' ) + $outputPage = $this->getMockBuilder( OutputPage::class ) ->disableOriginalConstructor() ->getMock(); @@ -75,7 +74,7 @@ ->method( 'addModules' ) ->with( 'wikibase.client.page-move' ); - $movePageForm = $this->getMock( 'MovePageForm' ); + $movePageForm = $this->getMock( MovePageForm::class ); $movePageForm->expects( $this->once() ) ->method( 'getOutput' ) ->will( $this->returnValue( $outputPage ) ); diff --git a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php index 200f14f..0acad7c 100644 --- a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php +++ b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php @@ -223,7 +223,7 @@ ), ) ); - $lookup = $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ); + $lookup = $this->getMock( SiteLinkLookup::class ); $lookup->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) ->will( $this->returnValue( null ) ); @@ -290,7 +290,7 @@ private function getSiteLinkLookup() { $Q123 = new ItemId( 'Q123' ); - $lookup = $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ); + $lookup = $this->getMock( SiteLinkLookup::class ); $lookup->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) ->will( $this->returnValue( $Q123 ) ); diff --git a/client/tests/phpunit/includes/Hooks/ParserLimitHookHandlersTest.php b/client/tests/phpunit/includes/Hooks/ParserLimitHookHandlersTest.php index 1afb5c4..edfbab5 100644 --- a/client/tests/phpunit/includes/Hooks/ParserLimitHookHandlersTest.php +++ b/client/tests/phpunit/includes/Hooks/ParserLimitHookHandlersTest.php @@ -3,9 +3,11 @@ namespace Wikibase\Client\Tests\Hooks; use Language; +use Parser; use ParserOutput; use PHPUnit_Framework_TestCase; use Wikibase\Client\Hooks\ParserLimitHookHandlers; +use Wikibase\DataModel\Services\Lookup\RestrictedEntityLookup; /** * @covers Wikibase\Client\Hooks\ParserLimitHookHandlers @@ -20,7 +22,7 @@ class ParserLimitHookHandlersTest extends PHPUnit_Framework_TestCase { public function testDoParserLimitReportPrepare() { - $restrictedEntityLookup = $this->getMockBuilder( 'Wikibase\DataModel\Services\Lookup\RestrictedEntityLookup' ) + $restrictedEntityLookup = $this->getMockBuilder( RestrictedEntityLookup::class ) ->disableOriginalConstructor() ->getMock(); @@ -35,10 +37,7 @@ $parserOutput = new ParserOutput(); - $handler->doParserLimitReportPrepare( - $this->getMock( 'Parser' ), - $parserOutput - ); + $handler->doParserLimitReportPrepare( $this->getMock( Parser::class ), $parserOutput ); $limitReportData = $parserOutput->getLimitReportData(); @@ -49,7 +48,7 @@ * @dataProvider doParserLimitReportFormatProvider */ public function testDoParserLimitReportFormat( $expected, $isHTML, $localize ) { - $restrictedEntityLookup = $this->getMockBuilder( 'Wikibase\DataModel\Services\Lookup\RestrictedEntityLookup' ) + $restrictedEntityLookup = $this->getMockBuilder( RestrictedEntityLookup::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php b/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php index 6cf3d8f..a19ead6 100644 --- a/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php +++ b/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php @@ -18,6 +18,7 @@ use Wikibase\Client\WikibaseClient; use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup; use Wikibase\DataModel\SiteLink; use Wikibase\DataModel\SiteLinkList; use Wikibase\DataModel\Term\Term; @@ -193,9 +194,7 @@ } private function getBadgeDisplay() { - $labelDescriptionLookup = $this->getMockBuilder( - 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' - ) + $labelDescriptionLookup = $this->getMockBuilder( LabelDescriptionLookup::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/SidebarHookHandlersTest.php b/client/tests/phpunit/includes/Hooks/SidebarHookHandlersTest.php index 8981a11..9c6fda4 100644 --- a/client/tests/phpunit/includes/Hooks/SidebarHookHandlersTest.php +++ b/client/tests/phpunit/includes/Hooks/SidebarHookHandlersTest.php @@ -47,9 +47,7 @@ * @return LabelDescriptionLookup */ private function getLabelDescriptionLookup( array $siteLinksPerItem ) { - $labelLookup = $this->getMockBuilder( - 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' - ) + $labelLookup = $this->getMockBuilder( LabelDescriptionLookup::class ) ->disableOriginalConstructor() ->getMock(); @@ -90,7 +88,7 @@ * @return OtherProjectsSidebarGenerator */ private function getSidebarGenerator( array $projects ) { - $sidebarGenerator = $this->getMockBuilder( 'Wikibase\Client\Hooks\OtherProjectsSidebarGenerator' ) + $sidebarGenerator = $this->getMockBuilder( OtherProjectsSidebarGenerator::class ) ->disableOriginalConstructor() ->getMock(); @@ -110,7 +108,7 @@ $otherProjectsSidebarGenerator = $this->getSidebarGenerator( $projects ); $otherProjectsSidebarGeneratorFactory = $this->getMockBuilder( - 'Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory' + OtherProjectsSidebarGeneratorFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -262,7 +260,7 @@ * @return Skin */ private function newSkin( IContextSource $context ) { - $skin = $this->getMockBuilder( 'Skin' ) + $skin = $this->getMockBuilder( Skin::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Hooks/SkinTemplateOutputPageBeforeExecHandlerTest.php b/client/tests/phpunit/includes/Hooks/SkinTemplateOutputPageBeforeExecHandlerTest.php index ad8b6fa..d9a7332 100644 --- a/client/tests/phpunit/includes/Hooks/SkinTemplateOutputPageBeforeExecHandlerTest.php +++ b/client/tests/phpunit/includes/Hooks/SkinTemplateOutputPageBeforeExecHandlerTest.php @@ -9,7 +9,11 @@ use PHPUnit_Framework_TestCase; use Skin; use SkinFallbackTemplate; +use SkinTemplate; +use Title; use Wikibase\Client\Hooks\SkinTemplateOutputPageBeforeExecHandler; +use Wikibase\Client\RepoItemLinkGenerator; +use WikiPage; /** * @covers Wikibase\Client\Hooks\SkinTemplateOutputPageBeforeExecHandler @@ -74,7 +78,7 @@ } private function newSkinTemplateOutputPageBeforeExecHandler( $link = null ) { - $repoItemLinkGenerator = $this->getMockBuilder( 'Wikibase\Client\RepoItemLinkGenerator' ) + $repoItemLinkGenerator = $this->getMockBuilder( RepoItemLinkGenerator::class ) ->disableOriginalConstructor() ->getMock(); @@ -102,7 +106,7 @@ * @return SkinFallbackTemplate */ private function getTemplate( $languageUrls, &$actualLanguageUrls, &$actualWbeditlanglinks = null ) { - $template = $this->getMock( 'SkinFallbackTemplate' ); + $template = $this->getMock( SkinFallbackTemplate::class ); $template->expects( $this->any() ) ->method( 'get' ) @@ -130,13 +134,13 @@ * @return Skin */ private function getSkin( array $noexternallanglinks = null ) { - $skin = $this->getMock( 'SkinTemplate' ); + $skin = $this->getMock( SkinTemplate::class ); $output = new OutputPage( $this->getContext() ); $output->setProperty( 'noexternallanglinks', $noexternallanglinks ); $output->setProperty( 'wikibase_item', 'Q2013' ); - $title = $this->getMock( 'Title' ); + $title = $this->getMock( Title::class ); $title->expects( $this->any() ) ->method( 'exists' ) ->will( $this->returnValue( true ) ); @@ -160,14 +164,14 @@ private function getContext() { $request = new FauxRequest( array( 'action' => 'view' ) ); - $wikiPage = $this->getMockBuilder( 'WikiPage' ) + $wikiPage = $this->getMockBuilder( WikiPage::class ) ->disableOriginalConstructor() ->getMock(); $wikiPage->expects( $this->any() ) ->method( 'getActionOverrides' ) ->will( $this->returnValue( array() ) ); - $context = $this->getMock( 'IContextSource' ); + $context = $this->getMock( IContextSource::class ); $context->expects( $this->any() ) ->method( 'canUseWikiPage' ) ->will( $this->returnValue( true ) ); diff --git a/client/tests/phpunit/includes/LangLinkHandlerTest.php b/client/tests/phpunit/includes/LangLinkHandlerTest.php index f562a93..03cd116 100644 --- a/client/tests/phpunit/includes/LangLinkHandlerTest.php +++ b/client/tests/phpunit/includes/LangLinkHandlerTest.php @@ -95,7 +95,7 @@ * @return LanguageLinkBadgeDisplay */ private function getLanguageLinkBadgeDisplay() { - $badgeDisplay = $this->getMockBuilder( 'Wikibase\Client\Hooks\LanguageLinkBadgeDisplay' ) + $badgeDisplay = $this->getMockBuilder( LanguageLinkBadgeDisplay::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Modules/SiteModuleTest.php b/client/tests/phpunit/includes/Modules/SiteModuleTest.php index a7e58e9..4567053 100644 --- a/client/tests/phpunit/includes/Modules/SiteModuleTest.php +++ b/client/tests/phpunit/includes/Modules/SiteModuleTest.php @@ -21,7 +21,7 @@ * @return ResourceLoaderContext */ private function getContext() { - return $this->getMockBuilder( 'ResourceLoaderContext' ) + return $this->getMockBuilder( ResourceLoaderContext::class ) ->disableOriginalConstructor() ->getMock(); } diff --git a/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php b/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php index 236d3e0..12cf257 100644 --- a/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php +++ b/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php @@ -389,7 +389,7 @@ * @return Title */ private function makeTitle( $ns, $text, $pageId, $currentRevision ) { - $title = $this->getMock( 'Title' ); + $title = $this->getMock( Title::class ); $title->expects( $this->any() ) ->method( 'getNamespace' ) diff --git a/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php b/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php index 1627048..59dab60 100644 --- a/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php +++ b/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php @@ -6,6 +6,7 @@ use Diff\DiffOp\DiffOpChange; use Diff\MapDiffer; use Language; +use SiteStore; use Title; use Wikibase\Client\RecentChanges\RecentChangeFactory; use Wikibase\DataModel\Entity\EntityId; @@ -30,7 +31,7 @@ * @return RecentChangeFactory */ private function newRecentChangeFactory() { - $siteStore = $this->getMock( 'SiteStore' ); + $siteStore = $this->getMock( SiteStore::class ); $lang = Language::factory( 'qqx' ); $siteLinkCommentCreator = new SiteLinkCommentCreator( $lang, $siteStore, 'testwiki' ); @@ -76,7 +77,7 @@ * @return Title */ private function newTitle( $ns, $text, $pageId, $revId, $length ) { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Serializer/ClientEntitySerializerTest.php b/client/tests/phpunit/includes/Serializer/ClientEntitySerializerTest.php index ce6d70f..0e93fb5 100644 --- a/client/tests/phpunit/includes/Serializer/ClientEntitySerializerTest.php +++ b/client/tests/phpunit/includes/Serializer/ClientEntitySerializerTest.php @@ -5,7 +5,9 @@ use PHPUnit_Framework_TestCase; use Wikibase\Client\Serializer\ClientEntitySerializer; use Wikibase\DataModel\Entity\Item; +use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup; use Wikibase\DataModel\Snak\PropertyNoValueSnak; +use Wikibase\LanguageFallbackChain; /** * @covers Wikibase\Client\Serializer\ClientEntitySerializer @@ -19,16 +21,14 @@ class ClientEntitySerializerTest extends PHPUnit_Framework_TestCase { private function newInstance() { - $fallbackChain = $this->getMockBuilder( 'Wikibase\LanguageFallbackChain' ) + $fallbackChain = $this->getMockBuilder( LanguageFallbackChain::class ) ->disableOriginalConstructor() ->getMock(); $fallbackChain->expects( $this->any() ) ->method( 'extractPreferredValue' ) ->will( $this->returnValue( array( 'source' => '<SOURCE>' ) ) ); - $dataTypeLookup = $this->getMock( - 'Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup' - ); + $dataTypeLookup = $this->getMock( PropertyDataTypeLookup::class ); $dataTypeLookup->expects( $this->any() ) ->method( 'getDataTypeIdForProperty' ) ->will( $this->returnValue( '<DATATYPE>' ) ); diff --git a/client/tests/phpunit/includes/SiteLinkCommentCreatorTest.php b/client/tests/phpunit/includes/SiteLinkCommentCreatorTest.php index f8672b1..53acdde 100644 --- a/client/tests/phpunit/includes/SiteLinkCommentCreatorTest.php +++ b/client/tests/phpunit/includes/SiteLinkCommentCreatorTest.php @@ -110,8 +110,13 @@ ); } + /** + * @param string $fullText + * + * @return Title + */ private function getTitle( $fullText ) { - $title = $this->getMockBuilder( 'Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Specials/SpecialPagesWithBadgesTest.php b/client/tests/phpunit/includes/Specials/SpecialPagesWithBadgesTest.php index 7013954..1826cb7 100644 --- a/client/tests/phpunit/includes/Specials/SpecialPagesWithBadgesTest.php +++ b/client/tests/phpunit/includes/Specials/SpecialPagesWithBadgesTest.php @@ -27,7 +27,7 @@ * @return LabelDescriptionLookup */ private function getLabelLookup() { - $labelLookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' ); + $labelLookup = $this->getMock( LabelDescriptionLookup::class ); $labelLookup->expects( $this->any() ) ->method( 'getLabel' ) ->will( $this->returnCallback( function( ItemId $id ) { @@ -46,7 +46,9 @@ new ItemId( 'Q456' ) ); - $labelDescriptionLookupFactory = $this->getMockBuilder( 'Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory' ) + $labelDescriptionLookupFactory = $this->getMockBuilder( + LanguageFallbackLabelDescriptionLookupFactory::class + ) ->disableOriginalConstructor() ->getMock(); $labelDescriptionLookupFactory->expects( $this->once() ) diff --git a/client/tests/phpunit/includes/Store/AddUsagesForPageJobTest.php b/client/tests/phpunit/includes/Store/AddUsagesForPageJobTest.php index 728e975..f5456c7 100644 --- a/client/tests/phpunit/includes/Store/AddUsagesForPageJobTest.php +++ b/client/tests/phpunit/includes/Store/AddUsagesForPageJobTest.php @@ -4,6 +4,7 @@ use Title; use Wikibase\Client\Store\AddUsagesForPageJob; +use Wikibase\Client\Store\UsageUpdater; use Wikibase\Client\Usage\EntityUsage; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\BasicEntityIdParser; @@ -125,7 +126,7 @@ 'touched' => '20150101000000' ); - $usageUpdater = $this->getMockBuilder( 'Wikibase\Client\Store\UsageUpdater' ) + $usageUpdater = $this->getMockBuilder( UsageUpdater::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Store/Sql/BulkSubscriptionUpdaterTest.php b/client/tests/phpunit/includes/Store/Sql/BulkSubscriptionUpdaterTest.php index 104b4c4..9a12ba2 100644 --- a/client/tests/phpunit/includes/Store/Sql/BulkSubscriptionUpdaterTest.php +++ b/client/tests/phpunit/includes/Store/Sql/BulkSubscriptionUpdaterTest.php @@ -253,7 +253,7 @@ * @return ExceptionHandler */ private function getExceptionHandler( PHPUnit_Framework_MockObject_Matcher_Invocation $matcher ) { - $mock = $this->getMock( 'Wikibase\Lib\Reporting\ExceptionHandler' ); + $mock = $this->getMock( ExceptionHandler::class ); $mock->expects( $matcher ) ->method( 'handleException' ); @@ -266,7 +266,7 @@ * @return MessageReporter */ private function getMessageReporter( PHPUnit_Framework_MockObject_Matcher_Invocation $matcher ) { - $mock = $this->getMock( 'Wikibase\Lib\Reporting\MessageReporter' ); + $mock = $this->getMock( MessageReporter::class ); $mock->expects( $matcher ) ->method( 'reportMessage' ); diff --git a/client/tests/phpunit/includes/Store/Sql/ConsistentReadConnectionManagerTest.php b/client/tests/phpunit/includes/Store/Sql/ConsistentReadConnectionManagerTest.php index 90eda79..cd9f808 100644 --- a/client/tests/phpunit/includes/Store/Sql/ConsistentReadConnectionManagerTest.php +++ b/client/tests/phpunit/includes/Store/Sql/ConsistentReadConnectionManagerTest.php @@ -2,6 +2,8 @@ namespace Wikibase\Client\Tests\Store\Sql; +use IDatabase; +use LoadBalancer; use Wikibase\Client\Store\Sql\ConsistentReadConnectionManager; /** @@ -16,12 +18,18 @@ */ class ConsistentReadConnectionManagerTest extends \PHPUnit_Framework_TestCase { + /** + * @return IDatabase + */ private function getConnectionMock() { - return $this->getMock( 'IDatabase' ); + return $this->getMock( IDatabase::class ); } + /** + * @return LoadBalancer + */ private function getLoadBalancerMock() { - $lb = $this->getMockBuilder( 'LoadBalancer' ) + $lb = $this->getMockBuilder( LoadBalancer::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php index 7546862..6281b8e 100644 --- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php +++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php @@ -3,11 +3,13 @@ namespace Wikibase\Client\Tests\UpdateRepo; use JobQueueGroup; +use JobQueueRedis; use JobSpecification; use Title; use User; use Wikibase\Client\UpdateRepo\UpdateRepoOnDelete; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\Lib\Store\SiteLinkLookup; /** * @covers Wikibase\Client\UpdateRepo\UpdateRepoOnDelete @@ -30,7 +32,7 @@ private function getFakeData() { $entityId = new ItemId( 'Q123' ); - $siteLinkLookupMock = $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ); + $siteLinkLookupMock = $this->getMock( SiteLinkLookup::class ); $siteLinkLookupMock->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) @@ -74,7 +76,7 @@ * @return JobQueueGroup */ private function getJobQueueGroupMock() { - $jobQueueGroupMock = $this->getMockBuilder( 'JobQueueGroup' ) + $jobQueueGroupMock = $this->getMockBuilder( JobQueueGroup::class ) ->disableOriginalConstructor() ->getMock(); @@ -88,7 +90,7 @@ // Use JobQueueRedis over here, as mocking abstract classes sucks // and it doesn't matter anyway - $jobQueue = $this->getMockBuilder( 'JobQueueRedis' ) + $jobQueue = $this->getMockBuilder( JobQueueRedis::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php index 6d7ac5b..235fdf6 100644 --- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php +++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php @@ -3,11 +3,13 @@ namespace Wikibase\Client\Tests\UpdateRepo; use JobQueueGroup; +use JobQueueRedis; use JobSpecification; use Title; use User; use Wikibase\Client\UpdateRepo\UpdateRepoOnMove; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\Lib\Store\SiteLinkLookup; /** * @covers Wikibase\Client\UpdateRepo\UpdateRepoOnMove @@ -30,7 +32,7 @@ private function getFakeMoveData() { $entityId = new ItemId( 'Q123' ); - $siteLinkLookupMock = $this->getMock( 'Wikibase\Lib\Store\SiteLinkLookup' ); + $siteLinkLookupMock = $this->getMock( SiteLinkLookup::class ); $siteLinkLookupMock->expects( $this->any() ) ->method( 'getItemIdForSiteLink' ) @@ -78,7 +80,7 @@ * @return JobQueueGroup */ private function getJobQueueGroupMock() { - $jobQueueGroupMock = $this->getMockBuilder( 'JobQueueGroup' ) + $jobQueueGroupMock = $this->getMockBuilder( JobQueueGroup::class ) ->disableOriginalConstructor() ->getMock(); @@ -92,7 +94,7 @@ // Use JobQueueRedis over here, as mocking abstract classes sucks // and it doesn't matter anyway - $jobQueue = $this->getMockBuilder( 'JobQueueRedis' ) + $jobQueue = $this->getMockBuilder( JobQueueRedis::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/client/tests/phpunit/includes/Usage/SiteLinkUsageLookupTest.php b/client/tests/phpunit/includes/Usage/SiteLinkUsageLookupTest.php index db7bdf1..09f5d6c 100644 --- a/client/tests/phpunit/includes/Usage/SiteLinkUsageLookupTest.php +++ b/client/tests/phpunit/includes/Usage/SiteLinkUsageLookupTest.php @@ -69,7 +69,7 @@ * @return TitleFactory */ private function getTitleFactory() { - $titleFactory = $this->getMock( 'Wikibase\Client\Store\TitleFactory' ); + $titleFactory = $this->getMock( TitleFactory::class ); $titleFactory->expects( $this->any() ) ->method( 'newFromText' ) ->will( $this->returnCallback( function( $text ) { diff --git a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableBuilderTest.php b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableBuilderTest.php index 18d42c4..39aa2c3 100644 --- a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableBuilderTest.php +++ b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableBuilderTest.php @@ -102,7 +102,7 @@ * @return ExceptionHandler */ private function getExceptionHandler( PHPUnit_Framework_MockObject_Matcher_Invocation $matcher ) { - $mock = $this->getMock( 'Wikibase\Lib\Reporting\ExceptionHandler' ); + $mock = $this->getMock( ExceptionHandler::class ); $mock->expects( $matcher ) ->method( 'handleException' ); @@ -115,7 +115,7 @@ * @return MessageReporter */ private function getMessageReporter( PHPUnit_Framework_MockObject_Matcher_Invocation $matcher ) { - $mock = $this->getMock( 'Wikibase\Lib\Reporting\MessageReporter' ); + $mock = $this->getMock( MessageReporter::class ); $mock->expects( $matcher ) ->method( 'reportMessage' ); diff --git a/client/tests/phpunit/includes/Usage/UsageTrackingSnakFormatterTest.php b/client/tests/phpunit/includes/Usage/UsageTrackingSnakFormatterTest.php index ecf908f..60db0fb 100644 --- a/client/tests/phpunit/includes/Usage/UsageTrackingSnakFormatterTest.php +++ b/client/tests/phpunit/includes/Usage/UsageTrackingSnakFormatterTest.php @@ -31,7 +31,7 @@ * @return SnakFormatter */ private function getMockSnakFormatter( $method, $return ) { - $mockFormatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' ); + $mockFormatter = $this->getMock( SnakFormatter::class ); $mockFormatter->expects( $this->once() ) ->method( $method ) diff --git a/client/tests/phpunit/includes/Usage/UsageTrackingTermLookupTest.php b/client/tests/phpunit/includes/Usage/UsageTrackingTermLookupTest.php index be90b26..8ae5a81 100644 --- a/client/tests/phpunit/includes/Usage/UsageTrackingTermLookupTest.php +++ b/client/tests/phpunit/includes/Usage/UsageTrackingTermLookupTest.php @@ -27,7 +27,7 @@ * @return TermLookup */ private function getMockTermLookup( $method, ItemId $entityId, $languageCode ) { - $mockLookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\TermLookup' ); + $mockLookup = $this->getMock( TermLookup::class ); $mockLookup->expects( $this->once() ) ->method( $method ) ->with( $entityId, $languageCode ) diff --git a/client/tests/phpunit/includes/UsageUpdaterTest.php b/client/tests/phpunit/includes/UsageUpdaterTest.php index 2fb8972..456c42f 100644 --- a/client/tests/phpunit/includes/UsageUpdaterTest.php +++ b/client/tests/phpunit/includes/UsageUpdaterTest.php @@ -4,6 +4,9 @@ use Wikibase\Client\Store\UsageUpdater; use Wikibase\Client\Usage\EntityUsage; +use Wikibase\Client\Usage\SubscriptionManager; +use Wikibase\Client\Usage\UsageLookup; +use Wikibase\Client\Usage\UsageTracker; use Wikibase\DataModel\Entity\ItemId; /** @@ -44,18 +47,18 @@ * @dataProvider addUsagesForPageProvider */ public function testAddUsagesForPage( $newUsage, $touched, $subscribe ) { - $usageTracker = $this->getMock( 'Wikibase\Client\Usage\UsageTracker' ); + $usageTracker = $this->getMock( UsageTracker::class ); $usageTracker->expects( $this->once() ) ->method( 'trackUsedEntities' ) ->with( 23, $newUsage, $touched ); - $usageLookup = $this->getMock( 'Wikibase\Client\Usage\UsageLookup' ); + $usageLookup = $this->getMock( UsageLookup::class ); $usageLookup->expects( $this->never() ) ->method( 'getUsagesForPage' ); $usageLookup->expects( $this->never() ) ->method( 'getUnusedEntities' ); - $subscriptionManager = $this->getMock( 'Wikibase\Client\Usage\SubscriptionManager' ); + $subscriptionManager = $this->getMock( SubscriptionManager::class ); $subscriptionManager->expects( $this->never() ) ->method( 'unsubscribe' ); @@ -112,13 +115,13 @@ * @dataProvider pruneUsagesForPageProvider */ public function testPruneUsagesForPage( $lastUpdatedBefore, $prunedUsages, $prunedEntityIds, $unused ) { - $usageTracker = $this->getMock( 'Wikibase\Client\Usage\UsageTracker' ); + $usageTracker = $this->getMock( UsageTracker::class ); $usageTracker->expects( $this->once() ) ->method( 'pruneStaleUsages' ) ->with( 23, $lastUpdatedBefore ) ->will( $this->returnValue( $prunedUsages ) ); - $usageLookup = $this->getMock( 'Wikibase\Client\Usage\UsageLookup' ); + $usageLookup = $this->getMock( UsageLookup::class ); $usageLookup->expects( $this->never() ) ->method( 'getUsagesForPage' ); $usageLookup->expects( $this->once() ) @@ -130,7 +133,7 @@ ) ) ->will( $this->returnValue( $unused ) ); - $subscriptionManager = $this->getMock( 'Wikibase\Client\Usage\SubscriptionManager' ); + $subscriptionManager = $this->getMock( SubscriptionManager::class ); $subscriptionManager->expects( $this->never() ) ->method( 'subscribe' ); -- To view, visit https://gerrit.wikimedia.org/r/275379 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I577208e75657864d2badb636659f87908fedf794 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits