jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/347327 )
Change subject: Do not use getMockBuilder() on interfaces
......................................................................
Do not use getMockBuilder() on interfaces
Interfaces do not have constructors, no need for
disableOriginalConstructor(). ;-) I found these with two regular
expressions. The first extracted all interface names in my local code
base, the second found getMockBuilder() calls with these interfaces.
Change-Id: I1cc80b958d1e277bcbfefe3fd78e3584663c299f
---
M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
M
client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
M client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
M client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
M client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
M client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php
M lib/tests/phpunit/Interactors/DispatchingTermSearchInteractorTest.php
M repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
M repo/tests/phpunit/includes/Api/ItemByTitleHelperTest.php
M repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
M repo/tests/phpunit/includes/Modules/MediaWikiConfigModuleTest.php
M repo/tests/phpunit/includes/ParserOutput/ReferencedEntitiesDataUpdaterTest.php
M repo/tests/phpunit/includes/Store/Sql/ItemsPerSiteBuilderTest.php
13 files changed, 21 insertions(+), 57 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
index 20745a4..1913e69 100644
---
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
+++
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
@@ -227,8 +227,7 @@
* @return SiteLinkLookup
*/
private function getSiteLinkLookup( ItemId $itemId ) {
- $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
- ->getMock();
+ $siteLinkLookup = $this->getMock( SiteLinkLookup::class );
$siteLinkLookup->expects( $this->once() )
->method( 'getItemIdForLink' )
@@ -293,9 +292,7 @@
* @return StatementGroupRenderer
*/
private function getRenderer( EntityId $entityId, $propertyLabelOrId ) {
- $renderer = $this->getMockBuilder(
StatementGroupRenderer::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $renderer = $this->getMock( StatementGroupRenderer::class );
$renderer->expects( $this->any() )
->method( 'render' )
diff --git
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
index 432b6a1..66cbb2c 100644
---
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
+++
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
@@ -241,9 +241,7 @@
* @return OutputFormatSnakFormatterFactory
*/
private function getSnakFormatterFactory() {
- $snakFormatter = $this->getMockBuilder( SnakFormatter::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $snakFormatter = $this->getMock( SnakFormatter::class );
$snakFormatter->expects( $this->any() )
->method( 'formatSnak' )
@@ -264,9 +262,7 @@
* @return EntityLookup
*/
private function getEntityLookup() {
- $entityLookup = $this->getMockBuilder( EntityLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $entityLookup = $this->getMock( EntityLookup::class );
$entityLookup->expects( $this->any() )
->method( 'getEntity' )
diff --git a/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
b/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
index af41020..4fff72e 100644
--- a/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
+++ b/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
@@ -112,9 +112,7 @@
], $text ?: $entityId );
} ) );
- $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $siteLinkLookup = $this->getMock( SiteLinkLookup::class );
$siteLinkLookup->expects( $this->any() )
->method( 'getItemIdForLink' )
@@ -139,9 +137,7 @@
->method( 'newLabelDescriptionLookup' )
->will( $this->returnCallback( [ $this,
'newLabelDescriptionLookup' ] ) );
- $idParser = $this->getMockBuilder( EntityIdParser::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $idParser = $this->getMock( EntityIdParser::class );
$idParser->expects( $this->any() )
->method( 'parse' )
@@ -178,9 +174,7 @@
* @return LabelDescriptionLookup
*/
public function newLabelDescriptionLookup() {
- $lookup = $this->getMockBuilder( LabelDescriptionLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $lookup = $this->getMock( LabelDescriptionLookup::class );
$lookup->expects( $this->any() )
->method( 'getLabel' )
diff --git a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
index 797d924..6615910 100644
--- a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
+++ b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
@@ -145,9 +145,7 @@
], $text ?: $entityId );
} ) );
- $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $siteLinkLookup = $this->getMock( SiteLinkLookup::class );
$siteLinkLookup->expects( $this->any() )
->method( 'getItemIdForLink' )
@@ -174,9 +172,7 @@
->method( 'newLabelDescriptionLookup' )
->will( $this->returnCallback( [ $this,
'newLabelDescriptionLookup' ] ) );
- $idParser = $this->getMockBuilder( EntityIdParser::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $idParser = $this->getMock( EntityIdParser::class );
$idParser->expects( $this->any() )
->method( 'parse' )
@@ -229,9 +225,7 @@
* @return LabelDescriptionLookup
*/
public function newLabelDescriptionLookup() {
- $lookup = $this->getMockBuilder( LabelDescriptionLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $lookup = $this->getMock( LabelDescriptionLookup::class );
$lookup->expects( $this->any() )
->method( 'getLabel' )
diff --git
a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
index c6907c3..268f4fe 100644
--- a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
+++ b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
@@ -30,9 +30,7 @@
* @return LanguageLinkBadgeDisplay
*/
private function getLanguageLinkBadgeDisplay() {
- $labelLookup = $this->getMockBuilder(
LabelDescriptionLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $labelLookup = $this->getMock( LabelDescriptionLookup::class );
$labelLookup->expects( $this->any() )
->method( 'getLabel' )
diff --git
a/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php
b/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php
index 5ea5282..534c9dd 100644
--- a/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php
+++ b/client/tests/phpunit/includes/Hooks/ParserOutputUpdateHookHandlersTest.php
@@ -179,9 +179,7 @@
}
private function getBadgeDisplay() {
- $labelDescriptionLookup = $this->getMockBuilder(
LabelDescriptionLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $labelDescriptionLookup = $this->getMock(
LabelDescriptionLookup::class );
$labelDescriptionLookup->expects( $this->any() )
->method( 'getLabel' )
diff --git
a/lib/tests/phpunit/Interactors/DispatchingTermSearchInteractorTest.php
b/lib/tests/phpunit/Interactors/DispatchingTermSearchInteractorTest.php
index d8f624b..689b3c6 100644
--- a/lib/tests/phpunit/Interactors/DispatchingTermSearchInteractorTest.php
+++ b/lib/tests/phpunit/Interactors/DispatchingTermSearchInteractorTest.php
@@ -43,7 +43,7 @@
}
private function getTermSearchInteractor( array $resultsByEntityType ) {
- $interactor = $this->getMockBuilder(
TermSearchInteractor::class )->getMock();
+ $interactor = $this->getMock( TermSearchInteractor::class );
$interactor->expects( $this->any() )
->method( 'searchForEntities' )
->will( $this->returnCallback(
diff --git a/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
b/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
index 8adfacf..798d575 100644
--- a/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
+++ b/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
@@ -83,9 +83,8 @@
* @return LabelDescriptionLookup
*/
private function getMockLabelDescriptionLookup() {
- $mock = $this->getMockBuilder( LabelDescriptionLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $mock = $this->getMock( LabelDescriptionLookup::class );
+
$mock->method( 'getLabel' )
->will( $this->returnValue( new Term(
self::DEFAULT_LANGUAGE, self::DEFAULT_LABEL ) ) );
$mock->method( 'getDescription' )
diff --git a/repo/tests/phpunit/includes/Api/ItemByTitleHelperTest.php
b/repo/tests/phpunit/includes/Api/ItemByTitleHelperTest.php
index e01ef84..3bc48a9 100644
--- a/repo/tests/phpunit/includes/Api/ItemByTitleHelperTest.php
+++ b/repo/tests/phpunit/includes/Api/ItemByTitleHelperTest.php
@@ -71,9 +71,7 @@
* @return SiteLinkLookup
*/
private function getSiteLinkLookupMock( $itemId ) {
- $siteLinkLookupMock = $this->getMockBuilder(
SiteLinkLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $siteLinkLookupMock = $this->getMock( SiteLinkLookup::class );
$siteLinkLookupMock->expects( $this->any() )
->method( 'getItemIdForLink' )
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
index a6f06e3..9ecc3e0 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
@@ -158,9 +158,7 @@
public function testValidate_() {
$item = new Item();
- $changeOp = $this->getMockBuilder( ChangeOp::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $changeOp = $this->getMock( ChangeOp::class );
$changeOp->expects( $this->any() )
->method( 'validate' )
->will( $this->returnCallback( function( Item $item ) {
diff --git a/repo/tests/phpunit/includes/Modules/MediaWikiConfigModuleTest.php
b/repo/tests/phpunit/includes/Modules/MediaWikiConfigModuleTest.php
index 7f98725..e8d3da6 100644
--- a/repo/tests/phpunit/includes/Modules/MediaWikiConfigModuleTest.php
+++ b/repo/tests/phpunit/includes/Modules/MediaWikiConfigModuleTest.php
@@ -42,9 +42,7 @@
private function newInstance() {
return new MediaWikiConfigModule( [ 'getconfigvalueprovider' =>
function () {
- $provider = $this->getMockBuilder(
MediaWikiConfigValueProvider::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $provider = $this->getMock(
MediaWikiConfigValueProvider::class );
$provider->expects( $this->any() )
->method( 'getKey' )
diff --git
a/repo/tests/phpunit/includes/ParserOutput/ReferencedEntitiesDataUpdaterTest.php
b/repo/tests/phpunit/includes/ParserOutput/ReferencedEntitiesDataUpdaterTest.php
index 6ad9375..a846506 100644
---
a/repo/tests/phpunit/includes/ParserOutput/ReferencedEntitiesDataUpdaterTest.php
+++
b/repo/tests/phpunit/includes/ParserOutput/ReferencedEntitiesDataUpdaterTest.php
@@ -51,9 +51,7 @@
* @return ReferencedEntitiesDataUpdater
*/
private function newInstance( $count = 0 ) {
- $entityTitleLookup = $this->getMockBuilder(
EntityTitleLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $entityTitleLookup = $this->getMock( EntityTitleLookup::class );
$entityTitleLookup->expects( $this->exactly( $count ) )
->method( 'getTitleForId' )
->will( $this->returnCallback( function( EntityId $id )
{
@@ -61,9 +59,7 @@
return Title::makeTitle( $namespace,
$id->getSerialization() );
} ) );
- $entityIdParser = $this->getMockBuilder( EntityIdParser::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $entityIdParser = $this->getMock( EntityIdParser::class );
$entityIdParser->expects( $this->any() )
->method( 'parse' )
->will( $this->returnCallback( function( $id ) {
diff --git a/repo/tests/phpunit/includes/Store/Sql/ItemsPerSiteBuilderTest.php
b/repo/tests/phpunit/includes/Store/Sql/ItemsPerSiteBuilderTest.php
index ceb2a58..7ad7e1e 100644
--- a/repo/tests/phpunit/includes/Store/Sql/ItemsPerSiteBuilderTest.php
+++ b/repo/tests/phpunit/includes/Store/Sql/ItemsPerSiteBuilderTest.php
@@ -58,9 +58,7 @@
* @return EntityLookup
*/
private function getEntityLookup() {
- $mock = $this->getMockBuilder( EntityLookup::class )
- ->disableOriginalConstructor()
- ->getMock();
+ $mock = $this->getMock( EntityLookup::class );
$item = $this->getTestItem();
$mock->expects( $this->exactly( 10 ) )
--
To view, visit https://gerrit.wikimedia.org/r/347327
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1cc80b958d1e277bcbfefe3fd78e3584663c299f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits