Daniel Kinzler has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/337029 )
Change subject: Support creation of empty entities.
......................................................................
Support creation of empty entities.
Bug: T157626
Change-Id: Ib423178ce6c5fe216ce6e7551baab2c3f0e1cd86
---
M repo/includes/Content/EntityHandler.php
M repo/tests/phpunit/includes/Content/EntityHandlerTest.php
2 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/29/337029/1
diff --git a/repo/includes/Content/EntityHandler.php
b/repo/includes/Content/EntityHandler.php
index b9fa380..ad872e0 100644
--- a/repo/includes/Content/EntityHandler.php
+++ b/repo/includes/Content/EntityHandler.php
@@ -19,6 +19,7 @@
use User;
use Wikibase\Content\DeferredDecodingEntityHolder;
use Wikibase\Content\EntityHolder;
+use Wikibase\Content\EntityInstanceHolder;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdParser;
@@ -219,7 +220,8 @@
* @return EntityContent
*/
public function makeEmptyContent() {
- throw new MWException( 'Cannot make an empty EntityContent,
since we require at least an ID to be set.' );
+ $empty = $this->makeEmptyEntity();
+ return $this->makeEntityContent( new EntityInstanceHolder(
$empty ) );
}
/**
diff --git a/repo/tests/phpunit/includes/Content/EntityHandlerTest.php
b/repo/tests/phpunit/includes/Content/EntityHandlerTest.php
index d2d8162..26a4cc6 100644
--- a/repo/tests/phpunit/includes/Content/EntityHandlerTest.php
+++ b/repo/tests/phpunit/includes/Content/EntityHandlerTest.php
@@ -312,11 +312,11 @@
}
public function testMakeEmptyContent() {
- // We don't support empty content.
- $this->setExpectedException( MWException::class );
-
$handler = $this->getHandler();
- $handler->makeEmptyContent();
+ $entity = $handler->makeEmptyContent()->getEntity();
+
+ $this->assertTrue( $entity->isEmpty(), 'isEmpty' );
+ $this->assertEquals( $handler->getEntityType(),
$entity->getType(), 'entity type' );
}
public function testMakeRedirectContent() {
@@ -331,6 +331,7 @@
$handler = $this->getHandler();
$entity = $handler->makeEmptyEntity();
+ $this->assertTrue( $entity->isEmpty(), 'isEmpty' );
$this->assertEquals( $handler->getEntityType(),
$entity->getType(), 'entity type' );
}
--
To view, visit https://gerrit.wikimedia.org/r/337029
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib423178ce6c5fe216ce6e7551baab2c3f0e1cd86
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits