diff core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children 12f9dff5fda9
line wrap: on
line diff
--- a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php	Thu Feb 28 11:14:44 2019 +0000
+++ b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php	Thu Feb 28 13:11:55 2019 +0000
@@ -5,7 +5,7 @@
 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;
@@ -202,7 +202,7 @@
     // 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);
 
@@ -211,12 +211,12 @@
       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(),
@@ -228,7 +228,7 @@
     // 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(),
@@ -250,13 +250,13 @@
           $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(),
@@ -271,12 +271,12 @@
       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(),
@@ -298,7 +298,7 @@
             $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(),