diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 717eed5..5289a02 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -289,10 +289,11 @@ public static function baseFieldDefinitions($entity_type) { ->setLabel(t('Entity type')) ->setDescription(t('The entity type to which this comment is attached.')); - $fields['field_id'] = FieldDefinition::create('entity_reference') + // @todo Convert to the entity_reference field in + // https://drupal.org/node/2149859. + $fields['field_id'] = FieldDefinition::create('string') ->setLabel(t('Field ID')) - ->setDescription(t('The comment field id.')) - ->setSetting('target_type', 'field_entity'); + ->setDescription(t('The comment field id.')); $fields['field_name'] = FieldDefinition::create('string') ->setLabel(t('Comment field name')) diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php index 90cac5d..220c4f8 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php @@ -44,6 +44,20 @@ public function setUp() { * Tests the comment validation constraints. */ public function testValidation() { + // Add comment field to content. + $this->entityManager->getStorageController('field_entity')->create(array( + 'entity_type' => 'node', + 'name' => 'comment', + 'type' => 'comment', + ))->save(); + // Add comment field instance to page content. + $this->entityManager->getStorageController('field_instance')->create(array( + 'field_name' => 'comment', + 'entity_type' => 'node', + 'bundle' => 'page', + 'label' => 'Comment settings', + ))->save(); + $node = $this->entityManager->getStorageController('node')->create(array( 'type' => 'page', 'title' => 'test', @@ -52,9 +66,8 @@ public function testValidation() { $comment = $this->entityManager->getStorageController('comment')->create(array( 'entity_id' => $node->id(), - // Just use some non-existing dummy field ID here, we are not testing - // that. - 'field_id' => 'test', + 'entity_type' => 'node', + 'field_name' => 'comment', )); $violations = $comment->validate(); $this->assertEqual(count($violations), 0, 'No violations when validating a default comment.');