jenkins-bot has submitted this change and it was merged.
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, 20 insertions(+), 1 deletion(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
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..bf75e2f 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,21 @@
$this->assertEquals( array( 10 ), $matchingInternalIds );
}
+ public function testFindMatchingEntitiesWithInvalidPropertyId() {
+ $matchFinder = new MatchFinderWithoutConstructor();
+
+ $description = new SomeProperty( new StringValue( 'nyan!' ),
new AnyValue() );
+ $queryOptions = new QueryOptions( 100, 0 );
+
+ $this->setExpectedException( 'InvalidArgumentException' );
+
+ $matchFinder->findMatchingEntities( $description, $queryOptions
);
+ }
+
+}
+
+class MatchFinderWithoutConstructor extends
\Wikibase\QueryEngine\SQLStore\Engine\DescriptionMatchFinder {
+
+ public function __construct(){}
+
}
--
To view, visit https://gerrit.wikimedia.org/r/66040
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ae68947c2c781d001702fc13881a31eaa1faa1d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Anja Jentzsch <[email protected]>
Gerrit-Reviewer: Ataherivand <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Jens Ohlig <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Lydia Pintscher <[email protected]>
Gerrit-Reviewer: Markus Kroetzsch <[email protected]>
Gerrit-Reviewer: Nikola Smolenski <[email protected]>
Gerrit-Reviewer: Silke Meyer <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits