Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75605


Change subject: InMemoryDataTypeLookup should throw PropertyNotFoundException
......................................................................

InMemoryDataTypeLookup should throw PropertyNotFoundException

...instead of OutOfBoundsException.

Change-Id: Ibb3e267cd00e2c88c8b461ef3a81d159571d14c1
---
M lib/includes/InMemoryDataTypeLookup.php
M lib/includes/PropertyDataTypeLookup.php
M lib/tests/phpunit/InMemoryDataTypeLookupTest.php
3 files changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/05/75605/1

diff --git a/lib/includes/InMemoryDataTypeLookup.php 
b/lib/includes/InMemoryDataTypeLookup.php
index 61344f1..eef70e7 100644
--- a/lib/includes/InMemoryDataTypeLookup.php
+++ b/lib/includes/InMemoryDataTypeLookup.php
@@ -51,7 +51,11 @@
                $this->verifyIdIsOfAProperty( $propertyId );
                $this->verifyDataTypeIsSet( $propertyId );
 
-               return $this->dataTypeIds[$propertyId->getNumericId()];
+               try {
+                       return $this->dataTypeIds[$propertyId->getNumericId()];
+               } catch ( OutOfBoundsException $ex ) {
+                       throw new PropertyNotFoundException( $propertyId );
+               }
        }
 
        /**
diff --git a/lib/includes/PropertyDataTypeLookup.php 
b/lib/includes/PropertyDataTypeLookup.php
index 7fe98e3..0273ad6 100644
--- a/lib/includes/PropertyDataTypeLookup.php
+++ b/lib/includes/PropertyDataTypeLookup.php
@@ -41,6 +41,7 @@
         * @param EntityId $propertyId
         *
         * @return string
+        * @throws PropertyNotFoundException
         */
        public function getDataTypeIdForProperty( EntityId $propertyId );
 
diff --git a/lib/tests/phpunit/InMemoryDataTypeLookupTest.php 
b/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
index 5e73c55..0790508 100644
--- a/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
+++ b/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
@@ -43,7 +43,7 @@
        public function testGetDataTypeForPropertyThatIsNotSet() {
                $lookup = new InMemoryDataTypeLookup();
 
-               $this->setExpectedException( 'OutOfBoundsException' );
+               $this->setExpectedException( 
'\Wikibase\PropertyNotFoundException' );
 
                $lookup->getDataTypeIdForProperty( new EntityId( 
Property::ENTITY_TYPE, 7201010 ) );
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb3e267cd00e2c88c8b461ef3a81d159571d14c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to