Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91860
Change subject: Implement EntityTable::removeEntity
......................................................................
Implement EntityTable::removeEntity
Change-Id: Ib6687ed00c32aa6b18640f5eb7e2163524dd7c4d
---
M src/SQLStore/EntityTable.php
M src/SQLStore/Store.php
M tests/Phpunit/SQLStore/EntityTableTest.php
3 files changed, 32 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQueryEngine
refs/changes/60/91860/1
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/Store.php b/src/SQLStore/Store.php
index 5c57dab..6bdba8d 100644
--- a/src/SQLStore/Store.php
+++ b/src/SQLStore/Store.php
@@ -165,6 +165,8 @@
return new SnakRemover( $this->getSnakStores() );
}
+ // This table is not yet needed.
+ // Later one it will be a dependency of the
EntityInserter/Remover/Updater
private function newEntityTable() {
return new EntityTable(
$this->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: newchange
Gerrit-Change-Id: Ib6687ed00c32aa6b18640f5eb7e2163524dd7c4d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQueryEngine
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits