Addshore has submitted this change and it was merged.

Change subject: Implement EntityTable::removeEntity
......................................................................


Implement EntityTable::removeEntity

Change-Id: Ib6687ed00c32aa6b18640f5eb7e2163524dd7c4d
---
M src/SQLStore/EntityTable.php
M src/SQLStore/SQLStore.php
M tests/Phpunit/SQLStore/EntityTableTest.php
3 files changed, 32 insertions(+), 4 deletions(-)

Approvals:
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/SQLStore/EntityTable.php b/src/SQLStore/EntityTable.php
index 8603434..e5c47be 100644
--- a/src/SQLStore/EntityTable.php
+++ b/src/SQLStore/EntityTable.php
@@ -46,14 +46,18 @@
                );
        }
 
-
        /**
         * @since 0.1
         *
         * @param Entity $entity
         */
        public function removeEntity( Entity $entity ) {
-
+               $this->queryInterface->delete(
+                       $this->entityTableName,
+                       array(
+                               'id' => $entity->getId()->getSerialization()
+                       )
+               );
        }
 
 }
diff --git a/src/SQLStore/SQLStore.php b/src/SQLStore/SQLStore.php
index 8c247a5..c8450f7 100644
--- a/src/SQLStore/SQLStore.php
+++ b/src/SQLStore/SQLStore.php
@@ -139,6 +139,8 @@
                return new SnakRemover( $this->getSnakStores( $queryInterface ) 
);
        }
 
+       // This table is not yet needed.
+       // Later one it will be a dependency of the 
EntityInserter/Remover/Updater
        private function newEntityTable( QueryInterface $queryInterface ) {
                return new EntityTable(
                        $queryInterface,
diff --git a/tests/Phpunit/SQLStore/EntityTableTest.php 
b/tests/Phpunit/SQLStore/EntityTableTest.php
index 8b50264..86f1da0 100644
--- a/tests/Phpunit/SQLStore/EntityTableTest.php
+++ b/tests/Phpunit/SQLStore/EntityTableTest.php
@@ -42,9 +42,9 @@
                                )
                        );
 
-               $inserter = new EntityTable( $queryInterface, 'nyan_entities' );
+               $table = new EntityTable( $queryInterface, 'nyan_entities' );
 
-               $inserter->insertEntity( $entity );
+               $table->insertEntity( $entity );
        }
 
        public function entityProvider() {
@@ -86,4 +86,26 @@
                return $claim;
        }
 
+       /**
+        * @dataProvider entityProvider
+        */
+       public function testRemoveEntity( Entity $entity ) {
+               $queryInterface = $this->getMock( 
'Wikibase\Database\QueryInterface\QueryInterface' );
+
+               $queryInterface->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with(
+                               $this->equalTo( 'nyan_entities' ),
+                               $this->equalTo(
+                                       array(
+                                               'id' => 
$entity->getId()->getSerialization()
+                                       )
+                               )
+                       );
+
+               $table = new EntityTable( $queryInterface, 'nyan_entities' );
+
+               $table->removeEntity( $entity );
+       }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6687ed00c32aa6b18640f5eb7e2163524dd7c4d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/WikibaseQueryEngine
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to