$author_name = 'This is a random & " > string';
$comment->
setOwnerId(0
)->
setAuthorName($author_name);
$input = '[comment:author]';
$output =
$token_service->
replace($input,
['comment' =>
$comment],
['langcode' =>
$language_interface->
getId()]);
$this->
assertSame((string) Html::
escape($author_name),
(string) $output);
// Add comment field to user and term entities.
$this->
addDefaultCommentField('user', 'user', 'comment', CommentItemInterface::OPEN, 'comment_user'
);
$this->
addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'comment_term'
);
// Create a user and a comment.
$user = User::
create(['name' => 'alice'
]);
$user->
activate();
$user->
save();
$this->
postComment($user, 'user body', 'user subject', TRUE
);
// Create a term and a comment.
$term = Term::
create([ 'vid' => 'tags',
'name' => 'term',
]);
$term->
save();
$this->
postComment($term, 'term body', 'term subject', TRUE
);