diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
index 90d4d1f..c4d2ad2 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
@@ -534,4 +534,16 @@ public function testAutocreateValidation() {
     $this->assertEqual(0, count($errors));
   }
 
+  /**
+   * Tests setting integer target ID and entity at the same time.
+   */
+  public function testSetValueWithIntegerTargetIdAndEntity() {
+    $user = User::create(['name' => $this->randomString()]);
+    $user->save();
+    // Tests that setting an integer target ID together with the entity object
+    // succeeds and does not cause any exceptions.
+    // @see \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::setValue().
+    $entity = EntityTest::create(['user_id' => ['target_id' => (int) $user->id(), 'entity' => $user]]);
+  }
+
 }
