diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php index c554c9115b..068bcdb883 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php @@ -96,6 +96,11 @@ protected function setUp($import_test_views = TRUE) { 'status' => 1, ]); $comment_anonymous->save(); + + // The entity fields for name and mail have retained their values when + // comment belongs to an anonymous user. + $this->assertNotNull($comment_anonymous->name->value); + $this->assertNotNull($comment_anonymous->mail->value); } /** @@ -150,7 +155,14 @@ public function testUsername() { $this->assertLink('My comment title'); $this->assertLink('Anonymous comment title'); - $this->assertNoLink($this->adminUser->label()); + // Display plugin of the view is showing the name field. When comment + // belongs to an authenticated user the name field has no value. + $comment_author = $this->xpath('//div[contains(@class, :class)]/span[normalize-space(text())=""]', [ + ':class' => 'views-field-subject', + ]); + $this->assertTrue(!empty($comment_author)); + // When comment belongs to an anonymous user the name field has a value and + // it is rendered correctly. $this->assertLink('barry (not verified)'); $account_switcher->switchTo(new AnonymousUserSession());