Jeroen De Dauw has uploaded a new change for review.

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


Change subject: Added exception that is thrown when getting an invalid property 
id
......................................................................

Added exception that is thrown when getting an invalid property id

Change-Id: I9ae68947c2c781d001702fc13881a31eaa1faa1d
---
M QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
M QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php
2 files changed, 15 insertions(+), 1 deletion(-)


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

diff --git a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php 
b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
index b038f01..55d8dde 100644
--- a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
+++ b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
@@ -6,6 +6,7 @@
 use Ask\Language\Description\SomeProperty;
 use Ask\Language\Description\ValueDescription;
 use Ask\Language\Option\QueryOptions;
+use InvalidArgumentException;
 use Wikibase\Database\QueryInterface;
 use Wikibase\EntityId;
 use Wikibase\Lib\EntityIdParser;
@@ -84,7 +85,7 @@
                $propertyId = $description->getPropertyId();
 
                if ( !( $propertyId instanceof EntityId ) ) {
-                       // TODO: Throw
+                       throw new InvalidArgumentException( 'All property ids 
provided to the SQLStore should be EntityId objects' );
                }
 
                $dvHandler = $this->schema->getDataValueHandler(
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php 
b/QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php
index 77518d1..8da3fba 100644
--- a/QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php
@@ -6,6 +6,7 @@
 use Ask\Language\Description\SomeProperty;
 use Ask\Language\Option\QueryOptions;
 use DataValues\PropertyValue;
+use DataValues\StringValue;
 use Wikibase\Database\FieldDefinition;
 use Wikibase\Database\TableDefinition;
 use Wikibase\EntityId;
@@ -117,4 +118,16 @@
                $this->assertEquals( array( 10 ), $matchingInternalIds );
        }
 
+       public function testFindMatchingEntitiesWithInvalidPropertyId() {
+               $matchFinderClass = new \ReflectionClass( 
'Wikibase\QueryEngine\SQLStore\Engine\DescriptionMatchFinder' );
+               $matchFinder = 
$matchFinderClass->newInstanceWithoutConstructor();
+
+               $description = new SomeProperty( new StringValue( 'nyan!' ), 
new AnyValue() );
+               $queryOptions = new QueryOptions( 100, 0 );
+
+               $this->setExpectedException( 'InvalidArgumentException' );
+
+               $matchFinder->findMatchingEntities( $description, $queryOptions 
);
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ae68947c2c781d001702fc13881a31eaa1faa1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

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

Reply via email to