use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Tests\CommentTestTrait;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
// Generate permutations.
$combinations = [
'comment' => [$comment1, $comment2, $comment3, $comment4],
- 'user' => [$comment_admin_user, $comment_enabled_user, $comment_no_edit_user, $comment_disabled_user, $anonymous_user]
+ 'user' => [$comment_admin_user, $comment_enabled_user, $comment_no_edit_user, $comment_disabled_user, $anonymous_user],
];
$permutations = $this->generatePermutations($combinations);
foreach ($permutations as $set) {
$may_view = $set['comment']->{$field}->access('view', $set['user']);
$may_update = $set['comment']->{$field}->access('edit', $set['user']);
- $this->assertTrue($may_view, SafeMarkup::format('User @user can view field @field on comment @comment', [
+ $this->assertTrue($may_view, new FormattableMarkup('User @user can view field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@comment' => $set['comment']->getSubject(),
'@field' => $field,
]));
- $this->assertEqual($may_update, $set['user']->hasPermission('administer comments'), SafeMarkup::format('User @user @state update field @field on comment @comment', [
+ $this->assertEqual($may_update, $set['user']->hasPermission('administer comments'), new FormattableMarkup('User @user @state update field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@state' => $may_update ? 'can' : 'cannot',
'@comment' => $set['comment']->getSubject(),
// Check access to normal field.
foreach ($permutations as $set) {
$may_update = $set['comment']->access('update', $set['user']) && $set['comment']->subject->access('edit', $set['user']);
- $this->assertEqual($may_update, $set['user']->hasPermission('administer comments') || ($set['user']->hasPermission('edit own comments') && $set['user']->id() == $set['comment']->getOwnerId()), SafeMarkup::format('User @user @state update field subject on comment @comment', [
+ $this->assertEqual($may_update, $set['user']->hasPermission('administer comments') || ($set['user']->hasPermission('edit own comments') && $set['user']->id() == $set['comment']->getOwnerId()), new FormattableMarkup('User @user @state update field subject on comment @comment', [
'@user' => $set['user']->getUsername(),
'@state' => $may_update ? 'can' : 'cannot',
'@comment' => $set['comment']->getSubject(),
$view_access = TRUE;
$state = 'can';
}
- $this->assertEqual($may_view, $view_access, SafeMarkup::format('User @user @state view field @field on comment @comment', [
+ $this->assertEqual($may_view, $view_access, new FormattableMarkup('User @user @state view field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@comment' => $set['comment']->getSubject(),
'@field' => $field,
'@state' => $state,
]));
- $this->assertFalse($may_update, SafeMarkup::format('User @user @state update field @field on comment @comment', [
+ $this->assertFalse($may_update, new FormattableMarkup('User @user @state update field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@state' => $may_update ? 'can' : 'cannot',
'@comment' => $set['comment']->getSubject(),
foreach ($permutations as $set) {
$may_view = $set['comment']->{$field}->access('view', $set['user']);
$may_update = $set['comment']->{$field}->access('edit', $set['user']);
- $this->assertEqual($may_view, TRUE, SafeMarkup::format('User @user can view field @field on comment @comment', [
+ $this->assertEqual($may_view, TRUE, new FormattableMarkup('User @user can view field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@comment' => $set['comment']->getSubject(),
'@field' => $field,
]));
- $this->assertEqual($may_update, $set['user']->hasPermission('post comments') && $set['comment']->isNew(), SafeMarkup::format('User @user @state update field @field on comment @comment', [
+ $this->assertEqual($may_update, $set['user']->hasPermission('post comments') && $set['comment']->isNew(), new FormattableMarkup('User @user @state update field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@state' => $may_update ? 'can' : 'cannot',
'@comment' => $set['comment']->getSubject(),
$set['comment']->isNew() &&
$set['user']->hasPermission('post comments') &&
$set['comment']->getFieldName() == 'comment_other'
- ), SafeMarkup::format('User @user @state update field @field on comment @comment', [
+ ), new FormattableMarkup('User @user @state update field @field on comment @comment', [
'@user' => $set['user']->getUsername(),
'@state' => $may_update ? 'can' : 'cannot',
'@comment' => $set['comment']->getSubject(),