diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 8d37a63ee438e0733a968bbb264c85b9b88894f5..d315b27139bd2a54b658dc6e82fa5274d0871b3b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -409,6 +409,7 @@ public function set($name, $value, $notify = TRUE) { // notified to handle changes afterwards. We can ignore notify as there is // no parent to notify anyway. $this->get($name)->setValue($value, TRUE); + return $this; } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 0960d4347b7337d7fc41b029a1f50a69aac300ff..b3bd6bd784c09f223aeb7bd941433f4206d34ad7 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -166,6 +166,9 @@ protected function setUp() { $this->fieldTypePluginManager->expects($this->any()) ->method('getDefaultFieldSettings') ->will($this->returnValue(array())); + $this->fieldTypePluginManager->expects($this->any()) + ->method('createFieldItemList') + ->will($this->returnValue($this->getMock('Drupal\Core\Field\FieldItemListInterface'))); $container = new ContainerBuilder(); $container->set('entity.manager', $this->entityManager); @@ -536,4 +539,15 @@ public function testGetFields($expected, $include_computed, $is_computed, $field ); } + /** + * @covers ::set + */ + public function testSet() { + // Exercise set(), check if it returns $this + $this->assertSame( + $this->entity, + $this->entity->set('id', 0) + ); + } + }