jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/337029 )

Change subject: Support creation of empty entities.
......................................................................


Support creation of empty entities.

Bug: T157626
Change-Id: Ib423178ce6c5fe216ce6e7551baab2c3f0e1cd86
Depends-On: I843f25172b70111f8219eec9a853ac3138c6aff3
---
M repo/includes/Content/EntityHandler.php
M repo/tests/phpunit/includes/Content/EntityHandlerTest.php
2 files changed, 8 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



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: merged
Gerrit-Change-Id: Ib423178ce6c5fe216ce6e7551baab2c3f0e1cd86
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to