// Check that the 'comment_body' field exists and has an instance on the
// new comment bundle.
$field_storage = FieldStorageConfig::
loadByName('comment', 'comment_body'
);
$this->
assertInstanceOf(FieldStorageConfig::
class,
$field_storage);
$field = FieldConfig::
loadByName('comment', 'comment', 'comment_body'
);
$this->
assertTrue(isset($field),
new FormattableMarkup('The comment_body field is present for comments on type @type',
['@type' =>
$type_name]));
// Test adding a field that defaults to CommentItemInterface::CLOSED.
$this->
addDefaultCommentField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies'
);
$field = FieldConfig::
load('node.test_node_type.who_likes_ponies'
);
$this->
assertEquals(CommentItemInterface::CLOSED,
$field->
getDefaultValueLiteral()[0
]['status'
]);
} /**
* Tests that you can remove a comment field.
*/
public function testCommentFieldDelete() { $this->
drupalCreateContentType(['type' => 'test_node_type'
]);
$this->
addDefaultCommentField('node', 'test_node_type'
);
// We want to test the handling of removing the primary comment field, so we
// ensure there is at least one other comment field attached to a node type
// so that comment_entity_load() runs for nodes.