Daniel Werner has submitted this change and it was merged. Change subject: Added NoValue and SomeValue SnakStores ......................................................................
Added NoValue and SomeValue SnakStores Change-Id: Ie1539c8c2dc162930f6916627e11805627127c19 --- M QueryEngine/QueryEngine.classes.php M QueryEngine/QueryEngine.mw.php A QueryEngine/QueryEngine/SQLStore/SnakStore/NoValueSnakStore.php A QueryEngine/QueryEngine/SQLStore/SnakStore/SomeValueSnakStore.php A QueryEngine/tests/phpunit/SQLStore/SnakStore/NoValueSnakStoreTest.php A QueryEngine/tests/phpunit/SQLStore/SnakStore/SomeValueSnakStoreTest.php 6 files changed, 224 insertions(+), 0 deletions(-) Approvals: Daniel Werner: Verified; Looks good to me, approved diff --git a/QueryEngine/QueryEngine.classes.php b/QueryEngine/QueryEngine.classes.php index 00708b8..6c307bc 100644 --- a/QueryEngine/QueryEngine.classes.php +++ b/QueryEngine/QueryEngine.classes.php @@ -43,8 +43,10 @@ 'Wikibase\QueryEngine\SQLStore\DVHandler\NumberHandler', 'Wikibase\QueryEngine\SQLStore\DVHandler\StringHandler', + 'Wikibase\QueryEngine\SQLStore\SnakStore\NoValueSnakStore', 'Wikibase\QueryEngine\SQLStore\SnakStore\PropertyValueSnakStore', 'Wikibase\QueryEngine\SQLStore\SnakStore\SnakStore', + 'Wikibase\QueryEngine\SQLStore\SnakStore\SomeValueSnakStore', 'Wikibase\QueryEngine\SQLStore\DataValueHandlers', 'Wikibase\QueryEngine\SQLStore\DataValueHandler', diff --git a/QueryEngine/QueryEngine.mw.php b/QueryEngine/QueryEngine.mw.php index 8fef61a..a3e8acd 100644 --- a/QueryEngine/QueryEngine.mw.php +++ b/QueryEngine/QueryEngine.mw.php @@ -85,7 +85,9 @@ 'SQLStore/DVHandler/NumberHandler', 'SQLStore/DVHandler/StringHandler', + 'SQLStore/SnakStore/NoValueSnakStore', 'SQLStore/SnakStore/PropertyValueSnakStore', + 'SQLStore/SnakStore/SomeValueSnakStore', 'SQLStore/DataValueHandlers', 'SQLStore/DataValueHandler', diff --git a/QueryEngine/QueryEngine/SQLStore/SnakStore/NoValueSnakStore.php b/QueryEngine/QueryEngine/SQLStore/SnakStore/NoValueSnakStore.php new file mode 100644 index 0000000..b4447f7 --- /dev/null +++ b/QueryEngine/QueryEngine/SQLStore/SnakStore/NoValueSnakStore.php @@ -0,0 +1,42 @@ +<?php + +namespace Wikibase\QueryEngine\SQLStore\SnakStore; + +use Wikibase\PropertyNoValueSnak; +use Wikibase\Snak; + +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 0.1 + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class NoValueSnakStore extends SnakStore { + + public function canStore( Snak $snak ) { + return $snak instanceof PropertyNoValueSnak; + } + + public function storeSnak( Snak $snak ) { + + } + +} diff --git a/QueryEngine/QueryEngine/SQLStore/SnakStore/SomeValueSnakStore.php b/QueryEngine/QueryEngine/SQLStore/SnakStore/SomeValueSnakStore.php new file mode 100644 index 0000000..2ffcfc0 --- /dev/null +++ b/QueryEngine/QueryEngine/SQLStore/SnakStore/SomeValueSnakStore.php @@ -0,0 +1,42 @@ +<?php + +namespace Wikibase\QueryEngine\SQLStore\SnakStore; + +use Wikibase\PropertySomeValueSnak; +use Wikibase\Snak; + +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 0.1 + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class SomeValueSnakStore extends SnakStore { + + public function canStore( Snak $snak ) { + return $snak instanceof PropertySomeValueSnak; + } + + public function storeSnak( Snak $snak ) { + + } + +} diff --git a/QueryEngine/tests/phpunit/SQLStore/SnakStore/NoValueSnakStoreTest.php b/QueryEngine/tests/phpunit/SQLStore/SnakStore/NoValueSnakStoreTest.php new file mode 100644 index 0000000..159d35b --- /dev/null +++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/NoValueSnakStoreTest.php @@ -0,0 +1,68 @@ +<?php + +namespace Wikibase\Tests\Query\SQLStore\SnakStore; + +use DataValues\StringValue; +use Wikibase\PropertyNoValueSnak; +use Wikibase\PropertySomeValueSnak; +use Wikibase\PropertyValueSnak; +use Wikibase\QueryEngine\SQLStore\SnakStore\NoValueSnakStore; +use Wikibase\Snak; + +/** + * Unit tests for the Wikibase\QueryEngine\SQLStore\SnakStore\NoValueSnakStore class. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQueryEngineTest + * + * @group Wikibase + * @group WikibaseQueryEngine + * @group WikibaseSnakStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class NoValueSnakStoreTest extends SnakStoreTest { + + protected function getInstance() { + return new NoValueSnakStore(); + } + + public function canStoreProvider() { + $argLists = array(); + + $argLists[] = array( false, new PropertyValueSnak( 42, new StringValue( 'nyan' ) ) ); + $argLists[] = array( false, new PropertyValueSnak( 9001, new StringValue( 'nyan' ) ) ); + $argLists[] = array( true, new PropertyNoValueSnak( 1 ) ); + $argLists[] = array( true, new PropertyNoValueSnak( 31337 ) ); + $argLists[] = array( false, new PropertySomeValueSnak( 2 ) ); + $argLists[] = array( false, new PropertySomeValueSnak( 720101 ) ); + + return $argLists; + } + + /** + * @dataProvider canStoreProvider + */ + public function testCanStore( $canStore, Snak $snak ) { + $this->assertEquals( $canStore, $this->getInstance()->canStore( $snak ) ); + } + +} diff --git a/QueryEngine/tests/phpunit/SQLStore/SnakStore/SomeValueSnakStoreTest.php b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SomeValueSnakStoreTest.php new file mode 100644 index 0000000..3a9b36b --- /dev/null +++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SomeValueSnakStoreTest.php @@ -0,0 +1,68 @@ +<?php + +namespace Wikibase\Tests\Query\SQLStore\SnakStore; + +use DataValues\StringValue; +use Wikibase\PropertyNoValueSnak; +use Wikibase\PropertySomeValueSnak; +use Wikibase\PropertyValueSnak; +use Wikibase\QueryEngine\SQLStore\SnakStore\SomeValueSnakStore; +use Wikibase\Snak; + +/** + * Unit tests for the Wikibase\QueryEngine\SQLStore\SnakStore\SomeValueSnakStore class. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQueryEngineTest + * + * @group Wikibase + * @group WikibaseQueryEngine + * @group WikibaseSnakStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class SomeValueSnakStoreTest extends SnakStoreTest { + + protected function getInstance() { + return new SomeValueSnakStore(); + } + + public function canStoreProvider() { + $argLists = array(); + + $argLists[] = array( false, new PropertyValueSnak( 42, new StringValue( 'nyan' ) ) ); + $argLists[] = array( false, new PropertyValueSnak( 9001, new StringValue( 'nyan' ) ) ); + $argLists[] = array( false, new PropertyNoValueSnak( 1 ) ); + $argLists[] = array( false, new PropertyNoValueSnak( 31337 ) ); + $argLists[] = array( true, new PropertySomeValueSnak( 2 ) ); + $argLists[] = array( true, new PropertySomeValueSnak( 720101 ) ); + + return $argLists; + } + + /** + * @dataProvider canStoreProvider + */ + public function testCanStore( $canStore, Snak $snak ) { + $this->assertEquals( $canStore, $this->getInstance()->canStore( $snak ) ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/58702 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie1539c8c2dc162930f6916627e11805627127c19 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: John Erling Blad <jeb...@gmail.com> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits