diff core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php	Thu May 09 15:34:47 2019 +0100
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\comment\Kernel;
 
+use Drupal\comment\CommentInterface;
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Entity\CommentType;
 use Drupal\comment\Tests\CommentTestTrait;
@@ -142,7 +143,7 @@
     // Change the second field's anonymous contact setting.
     $instance = FieldConfig::loadByName('entity_test', 'entity_test', 'comment_other');
     // Default is 'May not contact', for this field - they may contact.
-    $instance->setSetting('anonymous', COMMENT_ANONYMOUS_MAY_CONTACT);
+    $instance->setSetting('anonymous', CommentInterface::ANONYMOUS_MAY_CONTACT);
     $instance->save();
 
     // Create three "Comments". One is owned by our edit-enabled user.
@@ -212,12 +213,12 @@
         $may_view = $set['comment']->{$field}->access('view', $set['user']);
         $may_update = $set['comment']->{$field}->access('edit', $set['user']);
         $this->assertTrue($may_view, new FormattableMarkup('User @user can view field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
         ]));
         $this->assertEqual($may_update, $set['user']->hasPermission('administer comments'), new FormattableMarkup('User @user @state update field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
@@ -229,7 +230,7 @@
     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()), new FormattableMarkup('User @user @state update field subject on comment @comment', [
-        '@user' => $set['user']->getUsername(),
+        '@user' => $set['user']->getAccountName(),
         '@state' => $may_update ? 'can' : 'cannot',
         '@comment' => $set['comment']->getSubject(),
       ]));
@@ -251,13 +252,13 @@
           $state = 'can';
         }
         $this->assertEqual($may_view, $view_access, new FormattableMarkup('User @user @state view field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
           '@state' => $state,
         ]));
         $this->assertFalse($may_update, new FormattableMarkup('User @user @state update field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
@@ -272,12 +273,12 @@
         $may_view = $set['comment']->{$field}->access('view', $set['user']);
         $may_update = $set['comment']->{$field}->access('edit', $set['user']);
         $this->assertEqual($may_view, TRUE, new FormattableMarkup('User @user can view field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
         ]));
         $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(),
+          '@user' => $set['user']->getAccountName(),
           '@state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,
@@ -299,7 +300,7 @@
             $set['user']->hasPermission('post comments') &&
             $set['comment']->getFieldName() == 'comment_other'
           ), new FormattableMarkup('User @user @state update field @field on comment @comment', [
-          '@user' => $set['user']->getUsername(),
+          '@user' => $set['user']->getAccountName(),
           '@state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '@field' => $field,