jenkins-bot has submitted this change and it was merged.
Change subject: Remove not needed getters from DataUpdater implementations
......................................................................
Remove not needed getters from DataUpdater implementations
The only exception is ReferencedEntitiesDataUpdate. We already know we
need the information in a second place.
Bug: T114220
Change-Id: I0ce430901f20eacffe280a096c83cad46c8b3b02
---
M repo/includes/DataUpdates/ExternalLinksDataUpdate.php
M repo/includes/DataUpdates/ImageLinksDataUpdate.php
M repo/includes/DataUpdates/PageImagesDataUpdate.php
M repo/tests/phpunit/includes/DataUpdates/ExternalLinksDataUpdateTest.php
M repo/tests/phpunit/includes/DataUpdates/ImageLinksDataUpdateTest.php
M repo/tests/phpunit/includes/DataUpdates/PageImagesDataUpdateTest.php
M repo/tests/phpunit/includes/DataUpdates/ReferencedEntitiesDataUpdateTest.php
7 files changed, 39 insertions(+), 85 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/DataUpdates/ExternalLinksDataUpdate.php
b/repo/includes/DataUpdates/ExternalLinksDataUpdate.php
index df860d9..84ad832 100644
--- a/repo/includes/DataUpdates/ExternalLinksDataUpdate.php
+++ b/repo/includes/DataUpdates/ExternalLinksDataUpdate.php
@@ -40,13 +40,6 @@
}
/**
- * @return string[]
- */
- public function getExternalLinks() {
- return array_keys( $this->urls );
- }
-
- /**
* Add DataValue to list of used urls, if Snak property has 'url' data
type.
*
* @param Statement $statement
diff --git a/repo/includes/DataUpdates/ImageLinksDataUpdate.php
b/repo/includes/DataUpdates/ImageLinksDataUpdate.php
index f1a14c0..d67f71b 100644
--- a/repo/includes/DataUpdates/ImageLinksDataUpdate.php
+++ b/repo/includes/DataUpdates/ImageLinksDataUpdate.php
@@ -40,13 +40,6 @@
}
/**
- * @return string[]
- */
- public function getImageLinks() {
- return array_keys( $this->fileNames );
- }
-
- /**
* Add DataValue to list of used images if Snak property data type is
commonsMedia.
*
* @param Statement $statement
diff --git a/repo/includes/DataUpdates/PageImagesDataUpdate.php
b/repo/includes/DataUpdates/PageImagesDataUpdate.php
index 944aa53..c89f4f2 100644
--- a/repo/includes/DataUpdates/PageImagesDataUpdate.php
+++ b/repo/includes/DataUpdates/PageImagesDataUpdate.php
@@ -49,15 +49,6 @@
}
/**
- * Returns the one "best" image file name found after processing all
statements.
- *
- * @return string|null The file's page name without the NS_FILE
namespace, or null if not found.
- */
- public function getBestImageFileName() {
- return $this->bestFileName;
- }
-
- /**
* @see StatementDataUpdate::processStatement
*
* @param Statement $statement
diff --git
a/repo/tests/phpunit/includes/DataUpdates/ExternalLinksDataUpdateTest.php
b/repo/tests/phpunit/includes/DataUpdates/ExternalLinksDataUpdateTest.php
index 63a4f4d..9687367 100644
--- a/repo/tests/phpunit/includes/DataUpdates/ExternalLinksDataUpdateTest.php
+++ b/repo/tests/phpunit/includes/DataUpdates/ExternalLinksDataUpdateTest.php
@@ -50,25 +50,17 @@
/**
* @dataProvider externalLinksProvider
*/
- public function testGetExternalLinks( StatementList $statements, array
$expected ) {
- $instance = $this->newInstance();
-
- foreach ( $statements as $statement ) {
- $instance->processStatement( $statement );
- }
-
- $this->assertSame( $expected, $instance->getExternalLinks() );
- }
-
- /**
- * @dataProvider externalLinksProvider
- */
public function testUpdateParserOutput( StatementList $statements,
array $expected ) {
+ $actual = array();
+
$parserOutput = $this->getMockBuilder( 'ParserOutput' )
->disableOriginalConstructor()
->getMock();
$parserOutput->expects( $this->exactly( count( $expected ) ) )
- ->method( 'addExternalLink' );
+ ->method( 'addExternalLink' )
+ ->will( $this->returnCallback( function( $url ) use (
&$actual ) {
+ $actual[] = $url;
+ } ) );
$instance = $this->newInstance();
@@ -77,6 +69,7 @@
}
$instance->updateParserOutput( $parserOutput );
+ $this->assertSame( $expected, $actual );
}
public function externalLinksProvider() {
diff --git
a/repo/tests/phpunit/includes/DataUpdates/ImageLinksDataUpdateTest.php
b/repo/tests/phpunit/includes/DataUpdates/ImageLinksDataUpdateTest.php
index a98feb9..9cbe80a 100644
--- a/repo/tests/phpunit/includes/DataUpdates/ImageLinksDataUpdateTest.php
+++ b/repo/tests/phpunit/includes/DataUpdates/ImageLinksDataUpdateTest.php
@@ -50,25 +50,17 @@
/**
* @dataProvider imageLinksProvider
*/
- public function testGetImageLinks( StatementList $statements, array
$expected ) {
- $instance = $this->newInstance();
-
- foreach ( $statements as $statement ) {
- $instance->processStatement( $statement );
- }
-
- $this->assertSame( $expected, $instance->getImageLinks() );
- }
-
- /**
- * @dataProvider imageLinksProvider
- */
public function testUpdateParserOutput( StatementList $statements,
array $expected ) {
+ $actual = array();
+
$parserOutput = $this->getMockBuilder( 'ParserOutput' )
->disableOriginalConstructor()
->getMock();
$parserOutput->expects( $this->exactly( count( $expected ) ) )
- ->method( 'addImage' );
+ ->method( 'addImage' )
+ ->will( $this->returnCallback( function( $name ) use (
&$actual ) {
+ $actual[] = $name;
+ } ) );
$instance = $this->newInstance();
@@ -77,6 +69,7 @@
}
$instance->updateParserOutput( $parserOutput );
+ $this->assertSame( $expected, $actual );
}
public function imageLinksProvider() {
diff --git
a/repo/tests/phpunit/includes/DataUpdates/PageImagesDataUpdateTest.php
b/repo/tests/phpunit/includes/DataUpdates/PageImagesDataUpdateTest.php
index f7fbb2c..8f5bab3 100644
--- a/repo/tests/phpunit/includes/DataUpdates/PageImagesDataUpdateTest.php
+++ b/repo/tests/phpunit/includes/DataUpdates/PageImagesDataUpdateTest.php
@@ -73,23 +73,6 @@
/**
* @dataProvider bestImageProvider
*/
- public function testGetBestImageFileName(
- StatementList $statements,
- array $propertyIds,
- $expected
- ) {
- $instance = $this->newInstance( $propertyIds );
-
- foreach ( $statements as $statement ) {
- $instance->processStatement( $statement );
- }
-
- $this->assertSame( $expected, $instance->getBestImageFileName()
);
- }
-
- /**
- * @dataProvider bestImageProvider
- */
public function testUpdateParserOutput(
StatementList $statements,
array $propertyIds,
diff --git
a/repo/tests/phpunit/includes/DataUpdates/ReferencedEntitiesDataUpdateTest.php
b/repo/tests/phpunit/includes/DataUpdates/ReferencedEntitiesDataUpdateTest.php
index 7c736c9..622051d 100644
---
a/repo/tests/phpunit/includes/DataUpdates/ReferencedEntitiesDataUpdateTest.php
+++
b/repo/tests/phpunit/includes/DataUpdates/ReferencedEntitiesDataUpdateTest.php
@@ -8,7 +8,6 @@
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\SiteLinkList;
use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\DataModel\Statement\StatementList;
@@ -95,7 +94,10 @@
}
}
- $this->assertEquals( $expected, $instance->getEntityIds() );
+ $actual = array_map( function( EntityId $id ) {
+ return $id->getSerialization();
+ }, $instance->getEntityIds() );
+ $this->assertSame( $expected, $actual );
}
/**
@@ -106,11 +108,16 @@
SiteLinkList $siteLinks = null,
array $expected
) {
+ $actual = array();
+
$parserOutput = $this->getMockBuilder( 'ParserOutput' )
->disableOriginalConstructor()
->getMock();
$parserOutput->expects( $this->exactly( count( $expected ) ) )
- ->method( 'addLink' );
+ ->method( 'addLink' )
+ ->will( $this->returnCallback( function( Title $title )
use ( &$actual ) {
+ $actual[] = $title->getText();
+ } ) );
$instance = $this->newInstance( count( $expected ) );
@@ -125,6 +132,7 @@
}
$instance->updateParserOutput( $parserOutput );
+ $this->assertArrayEquals( $expected, $actual );
}
public function entityIdProvider() {
@@ -145,28 +153,28 @@
array( new StatementList(), null, array(
) ),
array( $set1, null, array(
- new PropertyId( 'P1' ),
- new ItemId( 'Q1' ),
+ 'P1',
+ 'Q1',
) ),
array( new StatementList(), $siteLinks, array(
- new ItemId( 'Q1' ),
+ 'Q1',
) ),
array( $set1, $siteLinks, array(
- new PropertyId( 'P1' ),
- new ItemId( 'Q1' ),
+ 'P1',
+ 'Q1',
) ),
array( $set2, null, array(
- new PropertyId( 'P1' ),
- new ItemId( 'Q20' ),
- new ItemId( 'Q21' ),
- new ItemId( 'Q22' ),
+ 'P1',
+ 'Q20',
+ 'Q21',
+ 'Q22',
) ),
array( $set2, $siteLinks, array(
- new PropertyId( 'P1' ),
- new ItemId( 'Q20' ),
- new ItemId( 'Q21' ),
- new ItemId( 'Q22' ),
- new ItemId( 'Q1' ),
+ 'P1',
+ 'Q20',
+ 'Q21',
+ 'Q22',
+ 'Q1',
) ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/246286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ce430901f20eacffe280a096c83cad46c8b3b02
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits