diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php index 02b2eb0b23c76a1ddd8d18e00e8caf737f4d63e3..23ccd78f487a1f3c2ba207504a7893cdc3fa7492 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\comment\Kernel\Views; use Drupal\comment\Entity\Comment; +use Drupal\comment\Entity\CommentType; use Drupal\Core\Session\AnonymousUserSession; use Drupal\entity_test\Entity\EntityTest; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; @@ -56,7 +57,11 @@ protected function setUp($import_test_views = TRUE): void { $admin_role = Role::create([ 'id' => 'admin', - 'permissions' => ['administer comments', 'access user profiles'], + 'permissions' => [ + 'administer comments', + 'access user profiles', + 'view test entity', + ], 'label' => 'Admin', ]); $admin_role->save(); @@ -75,6 +80,13 @@ protected function setUp($import_test_views = TRUE): void { $host = EntityTest::create(['name' => $this->randomString()]); $host->save(); + $commentType = CommentType::create([ + 'id' => 'entity_test_comment', + 'label' => t('Entity Test Comment'), + 'target_entity_type_id' => 'entity_test', + ]); + $commentType->save(); + // Create some comments. $comment = Comment::create([ 'subject' => 'My comment title', @@ -83,7 +95,7 @@ protected function setUp($import_test_views = TRUE): void { 'entity_type' => 'entity_test', 'field_name' => 'comment', 'entity_id' => $host->id(), - 'comment_type' => 'entity_test', + 'comment_type' => 'entity_test_comment', 'status' => 1, ]); $comment->save(); @@ -97,7 +109,7 @@ protected function setUp($import_test_views = TRUE): void { 'entity_type' => 'entity_test', 'field_name' => 'comment', 'entity_id' => $host->id(), - 'comment_type' => 'entity_test', + 'comment_type' => 'entity_test_comment', 'created' => 123456, 'status' => 1, ]);