jenkins-bot has submitted this change and it was merged. Change subject: [DNM] Drop unused EntityTestHelper::getTestEntity() method ......................................................................
[DNM] Drop unused EntityTestHelper::getTestEntity() method I found this while searching for deprecated DataModel methods. Some of this code is actually broken and should cause serious errors. I was wondering why this does not happen. Reason is: this is never executed. This patch actually reverts Ifdd5b29! It's *newer* code that was introduced to replace *older* code but was never used and is outdated now. What to do? Fix it and start using it? Is this worth our time? Bug: T78290 Change-Id: I928db375cd1c222b5d9fdedbbc89990fdefa2ff5 --- M repo/tests/phpunit/includes/api/EntityTestHelper.php M repo/tests/phpunit/includes/api/WikibaseApiTestCase.php 2 files changed, 0 insertions(+), 280 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/tests/phpunit/includes/api/EntityTestHelper.php b/repo/tests/phpunit/includes/api/EntityTestHelper.php index 24dbff0..642bea2 100644 --- a/repo/tests/phpunit/includes/api/EntityTestHelper.php +++ b/repo/tests/phpunit/includes/api/EntityTestHelper.php @@ -4,20 +4,6 @@ use DataValues\StringValue; use OutOfBoundsException; -use Wikibase\DataModel\Claim\Claim; -use Wikibase\DataModel\Entity\Entity; -use Wikibase\DataModel\Entity\EntityId; -use Wikibase\DataModel\Entity\Item; -use Wikibase\DataModel\Entity\ItemId; -use Wikibase\DataModel\Entity\Property; -use Wikibase\DataModel\Entity\PropertyId; -use Wikibase\DataModel\SiteLink; -use Wikibase\DataModel\Snak\PropertyValueSnak; -use Wikibase\DataModel\Term\AliasGroup; -use Wikibase\DataModel\Term\AliasGroupList; -use Wikibase\DataModel\Term\Fingerprint; -use Wikibase\DataModel\Term\Term; -use Wikibase\DataModel\Term\TermList; /** * @licence GNU GPL v2+ @@ -28,29 +14,21 @@ class EntityTestHelper { /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @var string[] List of currently active handles and their current ids */ private static $activeHandles = array(); /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @var string[] List of currently active ids and their current handles */ private static $activeIds; /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @var array[] Handles and any registered default output data */ private static $entityOutput = array(); /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @var array[] Set of pre defined entity data for use in tests */ private static $entityData = array( @@ -250,13 +228,6 @@ ); /** - * @var Entity[] filled by EntityTestHelper::fillTestEntities - */ - private static $testEntities = array(); - - /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Get the entity with the given handle * * @param string $handle String handle of entity to get data for @@ -278,8 +249,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Get the data to pass to the api to clear the entity with the given handle * * @param string $handle String handle of entity to get data for @@ -297,8 +266,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Get the data to pass to the api to create the entity with the given handle * * @param string $handle @@ -314,8 +281,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Get the data of the entity with the given handle we received after creation * * @param string $handle @@ -373,8 +338,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Register the entity after it has been created * * @param string $handle @@ -390,8 +353,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Unregister the entity after it has been cleared * * @param string $handle @@ -403,8 +364,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @return string[] List of currently active (registered) handles, using IDs as keys. */ public static function getActiveHandles() { @@ -412,8 +371,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @return string[] List of currently active (registered) IDs, using handles as keys. */ public static function getActiveIds() { @@ -421,8 +378,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Return the id for the entity with the given handle * * @param string $handle String handle of entity to get data for @@ -438,8 +393,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * @param $id string of entityid * @return null|string id of current handle (if active) */ @@ -473,233 +426,6 @@ } elseif ( is_string( $data ) ) { $data = str_replace( array_keys( $idMap ), array_values( $idMap ), $data ); } - } - - /** - * @since 0.5 - * - * @param EntityId|string $entityId - * - * @return null|Entity - */ - public static function getTestEntity( $entityId ) { - self::fillTestEntitiesIfEmpty(); - - if( $entityId instanceof EntityId ) { - $key = $entityId->getSerialization(); - } else { - $key = $entityId; - } - - if( array_key_exists( $key, self::$testEntities ) ) { - return self::$testEntities[ $key ]; - } else { - return null; - // FIXME? Should this throw an exception? - // throw new StorageException( 'Thrown by: ' . __CLASS__ . __METHOD__ ); - } - } - - /** - * Fills self::$testEntities with data (only if it is empty) - */ - private static function fillTestEntitiesIfEmpty() { - if( self::$testEntities === array() ) { - self::fillTestEntities(); - } - } - - /** - * Fills self::$testEntities with data - */ - private static function fillTestEntities() { - $entities = array(); - - $entities['Q1'] = new Item( new ItemId( 'Q1' ) ); - - $entities['Q2'] = new Item( new ItemId( 'Q2' ) ); - - $entities['P1'] = Property::newFromType( 'string' ); - $entities['P1']->setId( PropertyId::newFromNumber( 1 ) ); - - $entities['Q3'] = new Item( new ItemId( 'Q3' ) ); - $entities['Q3']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'Berlin' ), - new Term( 'en', 'Berlin' ), - new Term( 'nb', 'Berlin' ), - new Term( 'nn', 'Berlin' ), - ) - ), - new TermList( - array( - new Term( 'de', 'Bundeshauptstadt und Regierungssitz der Bundesrepublik Deutschland.' ), - new Term( 'en', 'Capital city and a federated state of the Federal Republic of Germany.' ), - new Term( 'nb', 'Hovedsted og delstat og i Forbundsrepublikken Tyskland.' ), - new Term( 'nn', 'Hovudstad og delstat i Forbundsrepublikken Tyskland.' ), - ) - ), - new AliasGroupList( - array( - new AliasGroup( 'de', array( 'Dickes B' ) ), - new AliasGroup( 'en', array( 'Dickes B' ) ), - new AliasGroup( 'nl', array( 'Dickes B' ) ), - ) - ) - ) - ); - $entities['Q3']->getSiteLinkList()->addNewSiteLink( 'dewiki', 'Berlin' ); - $entities['Q3']->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Berlin' ); - $entities['Q3']->getSiteLinkList()->addNewSiteLink( 'nlwiki', 'Berlin' ); - $entities['Q3']->getSiteLinkList()->addNewSiteLink( 'nnwiki', 'Berlin' ); - $claim = new Claim ( - new PropertyValueSnak( - PropertyId::newFromNumber( 1 ), - new StringValue( 'imastring1' ) - ) - ); - $claim->setGuid( 'Q3$E9DC0EA4-D0A0-429B-8F4D-048F2B5C9F73' ); - $entities['Q3']->addClaim( $claim ); - - $entities['Q4'] = new Item( new ItemId( 'Q4' ) ); - $entities['Q4']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'London' ), - new Term( 'en', 'London' ), - new Term( 'nb', 'London' ), - new Term( 'nn', 'London' ), - ) - ), - new TermList( - array( - new Term( 'de', 'Hauptstadt Englands und des Vereinigten Königreiches.' ), - new Term( 'en', 'Capital city of England and the United Kingdom.' ), - new Term( 'nb', 'Hovedsted i England og Storbritannia.' ), - new Term( 'nn', 'Hovudstad i England og Storbritannia.' ), - ) - ), - new AliasGroupList( - array( - new AliasGroup( 'de', array( 'City of London', 'Greater London' ) ), - new AliasGroup( 'en', array( 'City of London', 'Greater London' ) ), - new AliasGroup( 'nl', array( 'City of London', 'Greater London' ) ), - ) - ) - ) - ); - $entities['Q4']->getSiteLinkList()->addNewSiteLink( 'dewiki', 'London' ); - $entities['Q4']->getSiteLinkList()->addNewSiteLink( 'enwiki', 'London' ); - $entities['Q4']->getSiteLinkList()->addNewSiteLink( 'nlwiki', 'London' ); - $entities['Q4']->getSiteLinkList()->addNewSiteLink( 'nnwiki', 'London' ); - - $entities['Q5'] = new Item( new ItemId( 'Q5' ) ); - $entities['Q5']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'Oslo' ), - new Term( 'en', 'Oslo' ), - new Term( 'nb', 'Oslo' ), - new Term( 'nn', 'Oslo' ), - ) - ), - new TermList( - array( - new Term( 'de', 'Hauptstadt der Norwegen.' ), - new Term( 'en', 'Capital city in Norway.' ), - new Term( 'nb', 'Hovedsted i Norge.' ), - new Term( 'nn', 'Hovudstad i Noreg.' ), - ) - ), - new AliasGroupList( - array( - new AliasGroup( 'nb', array( 'Christiania', 'Kristiania' ) ), - new AliasGroup( 'nn', array( 'Christiania', 'Kristiania' ) ), - new AliasGroup( 'de', array( 'Oslo City' ) ), - new AliasGroup( 'en', array( 'Oslo City' ) ), - new AliasGroup( 'nl', array( 'Oslo City' ) ), - ) - ) - ) - ); - $entities['Q5']->getSiteLinkList()->addNewSiteLink( 'dewiki', 'Oslo' ); - $entities['Q5']->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Oslo' ); - $entities['Q5']->getSiteLinkList()->addNewSiteLink( 'nlwiki', 'Oslo' ); - $entities['Q5']->getSiteLinkList()->addNewSiteLink( 'nnwiki', 'Oslo' ); - - $entities['Q6'] = new Item( new ItemId( 'Q6' ) ); - $entities['Q6']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'Episkopi Cantonment' ), - new Term( 'en', 'Episkopi Cantonment' ), - new Term( 'nl', 'Episkopi Cantonment' ), - ) - ), - new TermList( - array( - new Term( 'de', 'Sitz der Verwaltung der Mittelmeerinsel Zypern.' ), - new Term( 'en', 'The capital of Akrotiri and Dhekelia.' ), - new Term( 'nl', 'Het bestuurlijke centrum van Akrotiri en Dhekelia.' ), - ) - ), - new AliasGroupList( - array( - new AliasGroup( 'de', array( 'Episkopi' ) ), - new AliasGroup( 'en', array( 'Episkopi' ) ), - new AliasGroup( 'nl', array( 'Episkopi' ) ), - ) - ) - ) - ); - $entities['Q6']->addSiteLink( new SiteLink( 'dewiki', 'Episkopi Cantonment' ) ); - $entities['Q6']->addSiteLink( new SiteLink( 'enwiki', 'Episkopi Cantonment' ) ); - $entities['Q6']->addSiteLink( new SiteLink( 'nlwiki', 'Episkopi Cantonment' ) ); - - $entities['Q7'] = new Item( new ItemId( 'Q7' ) ); - $entities['Q7']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'Leipzig' ), - ) - ), - new TermList( - array( - new Term( 'de', 'Stadt in Sachsen.' ), - new Term( 'en', 'City in Saxony.' ), - ) - ), - new AliasGroupList() - ) - ); - - $entities['Q8'] = new Item( new ItemId( 'Q8' ) ); - $entities['Q8']->setFingerprint( - new Fingerprint( - new TermList( - array( - new Term( 'de', 'Guangzhou' ), - new Term( 'yue', "廣州" ), - new Term( 'zh-cn', "广州市" ), - ) - ), - new TermList( - array( - new Term( 'en', 'Capital of Guangdong.' ), - new Term( 'zh-hk', "廣東的省會。" ), - ) - ), - new AliasGroupList() - ) - ); - - self::$testEntities = $entities; } } diff --git a/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php b/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php index 5987df7..a90102c 100644 --- a/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php +++ b/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php @@ -95,9 +95,6 @@ return $this->doApiRequest( $params, $session, false, $user ); } - /** - * @deprecated Please override the services in the API and use getTestEntity instead - */ protected function initTestEntities( array $handles, array $idMap = array() ) { $activeHandles = EntityTestHelper::getActiveHandles(); @@ -122,8 +119,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead - * * Loads an entity from the database (via an API call). */ protected function loadEntity( $id ) { @@ -138,7 +133,6 @@ } /** - * @deprecated Please override the services in the API and use getTestEntity instead * @see doTestQueryExceptions in IndependentWikibaseApiTestCase * * Do the test for exceptions from Api queries. -- To view, visit https://gerrit.wikimedia.org/r/202453 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I928db375cd1c222b5d9fdedbbc89990fdefa2ff5 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: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits