diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php
index 6efc6b6..936e03f 100644
--- a/core/modules/comment/src/Tests/CommentTypeTest.php
+++ b/core/modules/comment/src/Tests/CommentTypeTest.php
@@ -12,6 +12,8 @@
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\node\Entity\Node;
+use Drupal\node\NodeInterface;
+use Drupal\user\UserInterface;
 
 /**
  * Ensures that comment type functions work correctly.
@@ -189,4 +191,69 @@ public function testCommentTypeDeletion() {
     $this->assertRaw(t('The comment type %label has been deleted.', array('%label' => $type->label())));
   }
 
+  /**
+   * Tests comment entity_id field for entity reference properties.
+   */
+  public function testCommentEntityIdEntityReferenceProperties() {
+    // Create a comment type programmatically.
+    $node_comment_type = $this->createCommentType('node_comment_type');
+    $this->drupalCreateContentType(array('type' => 'page'));
+    $this->addDefaultCommentField('node', 'page', 'node_comment', CommentItemInterface::OPEN, 'node_comment_type');
+    $field_storage = FieldStorageConfig::loadByName('node', 'node_comment');
+
+    $this->assertEqual($field_storage->getSetting('target_type') , $node_comment_type->getTargetEntityTypeId());
+
+    $this->drupalLogin($this->adminUser);
+
+    // Create a node.
+    $node = Node::create(array(
+      'type' => 'page',
+      'title' => 'foo',
+    ));
+    $node->save();
+
+    // Add a new comment of this type.
+    $comment = Comment::create(array(
+      'comment_type' => 'node_comment_type',
+      'entity_type' => 'node',
+      'field_name' => 'node_comment',
+      'entity_id' => $node->id(),
+    ));
+    $comment->save();
+    $this->assertEqual($comment->entity_id->target_id, $node->id());
+    $this->assertEqual($comment->entity_id->target_type, 'node');
+    $this->assertTrue($comment->entity_id->entity instanceof NodeInterface);
+    $this->assertEqual($comment->entity_id->entity->id(), $node->id());
+    $this->assertEqual($comment->entity_id->entity->bundle(), $node->bundle());
+
+    // Create a comment type programmatically.
+    $user_comment_type = CommentType::create(array(
+      'id' => 'user_comment_type',
+      'label' => 'user_comment_type',
+      'description' => '',
+      'target_entity_type_id' => 'user',
+    ));
+    $user_comment_type->save();
+    $this->addDefaultCommentField('user', 'user', 'user_comment', CommentItemInterface::OPEN, 'user_comment_type');
+    $field_storage = FieldStorageConfig::loadByName('user', 'user_comment');
+    $this->assertEqual($field_storage->getSetting('target_type') , $user_comment_type->getTargetEntityTypeId());
+
+    $this->drupalLogin($this->adminUser);
+
+    // Add a new comment of this type.
+    $comment = Comment::create(array(
+      'comment_type' => 'user_comment_type',
+      'entity_type' => 'user',
+      'field_name' => 'user_comment',
+      'entity_id' => $this->adminUser->id(),
+    ));
+    $comment->save();
+    $this->assertEqual($comment->entity_id->target_id, $this->adminUser->id());
+    $this->assertEqual($comment->entity_id->target_type, 'user');
+    $this->assertTrue($comment->entity_id->entity instanceof UserInterface);
+    $this->assertEqual($comment->entity_id->entity->id(), $this->adminUser->id());
+    $this->assertEqual($comment->entity_id->entity->bundle(), $this->adminUser->bundle());
+
+  }
+
 }
