trait CommentTestTrait (View source)

Provides common functionality for the Comment test classes.

Methods

addDefaultCommentField(string $entity_type, string $bundle, string $field_name = 'comment', int $default_value = CommentItemInterface::OPEN, string $comment_type_id = 'comment', string $comment_view_mode = 'full')

Adds the default comment field to an entity.

Details

addDefaultCommentField(string $entity_type, string $bundle, string $field_name = 'comment', int $default_value = CommentItemInterface::OPEN, string $comment_type_id = 'comment', string $comment_view_mode = 'full')

Adds the default comment field to an entity.

Attaches a comment field named 'comment' to the given entity type and bundle. Largely replicates the default behavior in Drupal 7 and earlier.

Parameters

string $entity_type

The entity type to attach the default comment field to.

string $bundle

The bundle to attach the default comment field to.

string $field_name

(optional) Field name to use for the comment field. Defaults to 'comment'.

int $default_value

(optional) Default value, one of CommentItemInterface::HIDDEN, CommentItemInterface::OPEN, CommentItemInterface::CLOSED. Defaults to CommentItemInterface::OPEN.

string $comment_type_id

(optional) ID of comment type to use. Defaults to 'comment'.

string $comment_view_mode

(optional) The comment view mode to be used in comment field formatter. Defaults to 'full'.