jenkins-bot has submitted this change and it was merged.

Change subject: Always throw TermLookupException in EntityInfoTermLookup
......................................................................


Always throw TermLookupException in EntityInfoTermLookup

Also fix wrong exception in LabelDescriptionLookup mock

(squashed https://gerrit.wikimedia.org/r/#/c/237374/ from Thiemo)

Bug: T112003
Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
---
M lib/includes/store/EntityInfoTermLookup.php
M lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
M lib/tests/phpunit/store/EntityInfoTermLookupTest.php
3 files changed, 39 insertions(+), 15 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/store/EntityInfoTermLookup.php 
b/lib/includes/store/EntityInfoTermLookup.php
index 951acf7..6e69318 100644
--- a/lib/includes/store/EntityInfoTermLookup.php
+++ b/lib/includes/store/EntityInfoTermLookup.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Lib\Store;
 
+use OutOfBoundsException;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Services\Lookup\TermLookup;
 use Wikibase\DataModel\Services\Lookup\TermLookupException;
@@ -44,8 +45,13 @@
        public function getLabel( EntityId $entityId, $languageCode ) {
                try {
                        return $this->entityInfo->getLabel( $entityId, 
$languageCode );
-               } catch ( \OutOfBoundsException $ex ) {
-                       throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+               } catch ( OutOfBoundsException $ex ) {
+                       throw new TermLookupException(
+                               $entityId,
+                               array( $languageCode ),
+                               $ex->getMessage(),
+                               $ex
+                       );
                }
        }
 
@@ -53,13 +59,17 @@
         * Gets all labels of an Entity with the specified EntityId.
         *
         * @param EntityId $entityId
-        * @param string[] $languages
+        * @param string[] $languageCodes
         *
         * @throws TermLookupException
         * @return string[]
         */
-       public function getLabels( EntityId $entityId, array $languages ) {
-               return $this->entityInfo->getLabels( $entityId, $languages );
+       public function getLabels( EntityId $entityId, array $languageCodes ) {
+               try {
+                       return $this->entityInfo->getLabels( $entityId, 
$languageCodes );
+               } catch ( OutOfBoundsException $ex ) {
+                       throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+               }
        }
 
        /**
@@ -74,8 +84,13 @@
        public function getDescription( EntityId $entityId, $languageCode ) {
                try {
                        return $this->entityInfo->getDescription( $entityId, 
$languageCode );
-               } catch ( \OutOfBoundsException $ex ) {
-                       throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+               } catch ( OutOfBoundsException $ex ) {
+                       throw new TermLookupException(
+                               $entityId,
+                               array( $languageCode ),
+                               $ex->getMessage(),
+                               $ex
+                       );
                }
        }
 
@@ -83,13 +98,17 @@
         * Gets all descriptions of an Entity with the specified EntityId.
         *
         * @param EntityId $entityId
-        * @param string[] $languages
+        * @param string[] $languageCodes
         *
         * @throws TermLookupException
         * @return string[]
         */
-       public function getDescriptions( EntityId $entityId, array $languages ) 
{
-               return $this->entityInfo->getDescriptions( $entityId, 
$languages );
+       public function getDescriptions( EntityId $entityId, array 
$languageCodes ) {
+               try {
+                       return $this->entityInfo->getDescriptions( $entityId, 
$languageCodes );
+               } catch ( OutOfBoundsException $ex ) {
+                       throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+               }
        }
 
 }
diff --git a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php 
b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
index 2cc061d..b6d19ce 100644
--- a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
@@ -2,11 +2,12 @@
 
 namespace Wikibase\Lib\Test;
 
-use OutOfBoundsException;
+use MediaWikiTestCase;
 use Title;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup;
+use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookupException;
 use Wikibase\DataModel\Term\Term;
 use Wikibase\DataModel\Term\TermFallback;
 use Wikibase\Lib\EntityIdHtmlLinkFormatter;
@@ -23,7 +24,7 @@
  * @licence GNU GPL v2+
  * @author Marius Hoch < h...@online.de >
  */
-class EntityIdHtmlLinkFormatterTest extends \MediaWikiTestCase {
+class EntityIdHtmlLinkFormatterTest extends MediaWikiTestCase {
 
        /**
         * @param Term $term
@@ -46,7 +47,10 @@
                $labelDescriptionLookup = $this->getMock( 
'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' );
                $labelDescriptionLookup->expects( $this->any() )
                        ->method( 'getLabel' )
-                       ->will( $this->throwException( new 
OutOfBoundsException( 'meep' ) ) );
+                       ->will( $this->throwException( new 
LabelDescriptionLookupException(
+                               new ItemId( 'Q100' ),
+                               'meep'
+                       ) ) );
 
                return $labelDescriptionLookup;
        }
diff --git a/lib/tests/phpunit/store/EntityInfoTermLookupTest.php 
b/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
index d65492d..144dba6 100644
--- a/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
+++ b/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
@@ -4,6 +4,7 @@
 
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\DataModel\Services\Lookup\TermLookupException;
 use Wikibase\Lib\Store\EntityInfo;
 use Wikibase\Lib\Store\EntityInfoTermLookup;
 
@@ -72,7 +73,7 @@
        public function testGetLabels_noEntityThrowsException() {
                $termLookup = $this->getEntityInfoTermLookup();
 
-               $this->setExpectedException( 'OutOfBoundsException' );
+               $this->setExpectedException( 
'Wikibase\DataModel\Services\Lookup\TermLookupException' );
                $termLookup->getLabels( new ItemId( 'Q90000' ), array( 'x' ) );
        }
 
@@ -135,7 +136,7 @@
        public function testGetDescriptions_noEntityThrowsException() {
                $termLookup = $this->getEntityInfoTermLookup();
 
-               $this->setExpectedException( 'OutOfBoundsException' );
+               $this->setExpectedException( 
'Wikibase\DataModel\Services\Lookup\TermLookupException' );
                $termLookup->getDescriptions( new ItemId( 'Q90000' ), array( 
'x' ) );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/237357
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@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

Reply via email to