Denny Vrandecic has submitted this change and it was merged.

Change subject: Added QueryStoreUpdater tests
......................................................................


Added QueryStoreUpdater tests

Change-Id: Id954996598ab489de6720a86e60f47aa2dd55d8e
---
M QueryEngine/tests/phpunit/QueryStoreUpdaterTest.php
M QueryEngine/tests/phpunit/SQLStore/UpdaterTest.php
2 files changed, 89 insertions(+), 20 deletions(-)

Approvals:
  Denny Vrandecic: Verified; Looks good to me, approved



diff --git a/QueryEngine/tests/phpunit/QueryStoreUpdaterTest.php 
b/QueryEngine/tests/phpunit/QueryStoreUpdaterTest.php
index 0ba1279..737b61f 100644
--- a/QueryEngine/tests/phpunit/QueryStoreUpdaterTest.php
+++ b/QueryEngine/tests/phpunit/QueryStoreUpdaterTest.php
@@ -2,10 +2,11 @@
 
 namespace Wikibase\Test\Query;
 
-use Wikibase\QueryEngine\QueryStore;
+use Wikibase\Item;
+use Wikibase\QueryEngine\QueryStoreUpdater;
 
 /**
- * Base test class for Wikibase\QueryEngine\QueryStore implementing classes.
+ * Base test class for Wikibase\QueryEngine\QueryStoreUpdater implementing 
classes.
  *
  * 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
@@ -35,31 +36,58 @@
        /**
         * @since 0.1
         *
-        * @return QueryStore[]
+        * @return QueryStoreUpdater[]
         */
        protected abstract function getInstances();
 
        /**
         * @since 0.1
         *
-        * @return QueryStore[][]
+        * @return QueryStoreUpdater[][]
         */
        public function instanceProvider() {
                return $this->arrayWrap( $this->getInstances() );
        }
 
-       public function testInsertEntity() {
-               // TODO
+       /**
+        * @dataProvider instanceProvider
+        *
+        * @param QueryStoreUpdater $updater
+        */
+       public function testInsertEntityDoesNotFatal( QueryStoreUpdater 
$updater ) {
+               $item = Item::newEmpty();
+               $item->setId( 42 );
+
+               $updater->insertEntity( $item );
+
                $this->assertTrue( true );
        }
 
-       public function testUpdateEntity() {
-               // TODO
+       /**
+        * @dataProvider instanceProvider
+        *
+        * @param QueryStoreUpdater $updater
+        */
+       public function testUpdateEntityDoesNotFatal( QueryStoreUpdater 
$updater ) {
+               $item = Item::newEmpty();
+               $item->setId( 42 );
+
+               $updater->updateEntity( $item );
+
                $this->assertTrue( true );
        }
 
-       public function testDeleteEntity() {
-               // TODO
+       /**
+        * @dataProvider instanceProvider
+        *
+        * @param QueryStoreUpdater $updater
+        */
+       public function testDeleteEntityDoesNotFatal( QueryStoreUpdater 
$updater ) {
+               $item = Item::newEmpty();
+               $item->setId( 42 );
+
+               $updater->deleteEntity( $item );
+
                $this->assertTrue( true );
        }
 
diff --git a/QueryEngine/tests/phpunit/SQLStore/UpdaterTest.php 
b/QueryEngine/tests/phpunit/SQLStore/UpdaterTest.php
index d75d6e9..0596ec7 100644
--- a/QueryEngine/tests/phpunit/SQLStore/UpdaterTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/UpdaterTest.php
@@ -2,12 +2,17 @@
 
 namespace Wikibase\Test\Query\SQLStore;
 
-use Wikibase\Database\MWDB\ExtendedMySQLAbstraction;
-use Wikibase\Database\MediaWikiQueryInterface;
+use Wikibase\Database\FieldDefinition;
+use Wikibase\Database\ObservableQueryInterface;
+use Wikibase\Database\TableDefinition;
+use Wikibase\Item;
+use Wikibase\QueryEngine\SQLStore\DVHandler\BooleanHandler;
+use Wikibase\QueryEngine\SQLStore\DVHandler\MonolingualTextHandler;
+use Wikibase\QueryEngine\SQLStore\DVHandler\StringHandler;
+use Wikibase\QueryEngine\SQLStore\DataValueTable;
 use Wikibase\QueryEngine\SQLStore\Schema;
 use Wikibase\QueryEngine\SQLStore\StoreConfig;
 use Wikibase\QueryEngine\SQLStore\Updater;
-use Wikibase\Repo\LazyDBConnectionProvider;
 use Wikibase\Test\Query\QueryStoreUpdaterTest;
 
 /**
@@ -51,20 +56,56 @@
        protected function getInstances() {
                $instances = array();
 
-               $connectionProvider = new LazyDBConnectionProvider( DB_MASTER );
                $storeSchema = new Schema( new StoreConfig( 'foo', 'bar', 
array() ) );
-               $queryInterface = new MediaWikiQueryInterface(
-                       $connectionProvider,
-                       new ExtendedMySQLAbstraction( $connectionProvider )
-               );
+               $queryInterface = new ObservableQueryInterface();
 
                $instances[] = new Updater( $storeSchema, $queryInterface );
 
                return $instances;
        }
 
-       public function testFoo() {
-               // TODO
+       protected function newStoreSchema() {
+               $dataValueHandlers = array();
+
+               $dataValueHandlers['boolean'] = new BooleanHandler( new 
DataValueTable(
+                       new TableDefinition(
+                               'boolean',
+                               array(
+                                       new FieldDefinition( 'value', 
FieldDefinition::TYPE_BOOLEAN, false ),
+                               )
+                       ),
+                       'value',
+                       'value'
+               ) );
+
+               $dataValueHandlers['monolingualtext'] = new 
MonolingualTextHandler( new DataValueTable(
+                       new TableDefinition(
+                               'mono_text',
+                               array(
+                                       new FieldDefinition( 'text', 
FieldDefinition::TYPE_TEXT, false ),
+                                       new FieldDefinition( 'language', 
FieldDefinition::TYPE_TEXT, false ),
+                                       new FieldDefinition( 'json', 
FieldDefinition::TYPE_TEXT, false ),
+                               )
+                       ),
+                       'json',
+                       'text',
+                       'text'
+               ) );
+
+               return new Schema( new StoreConfig( 'foo', 'bar', 
$dataValueHandlers ) );
+       }
+
+       public function testInsertEntity() {
+               $item = Item::newEmpty();
+               $item->setId( 42 );
+
+               $queryInterface = new ObservableQueryInterface();
+
+               $updater = new Updater( $this->newStoreSchema(), 
$queryInterface );
+
+               $updater->insertEntity( $item );
+
+               // TODO: further implement
                $this->assertTrue( true );
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id954996598ab489de6720a86e60f47aa2dd55d8e
Gerrit-PatchSet: 4
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: Denny Vrandecic <denny.vrande...@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

Reply via email to