diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php index 2353d95..5a589e5 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php @@ -45,6 +45,7 @@ function testCommentPreview() { $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview')); $this->assertEscaped($this->webUser->getDisplayName()); + \Drupal::service('module_installer')->install(['user_hooks_test']); \Drupal::state()->set('user_hooks_test_user_format_name_alter_safe', TRUE); $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview')); $this->assertTrue($this->webUser->getDisplayName() instanceof MarkupInterface, 'Username is marked safe'); diff --git a/core/modules/search/src/Tests/SearchExactTest.php b/core/modules/search/src/Tests/SearchExactTest.php index 92e8e86..792a315 100644 --- a/core/modules/search/src/Tests/SearchExactTest.php +++ b/core/modules/search/src/Tests/SearchExactTest.php @@ -62,7 +62,7 @@ function testExactQuery() { $edit = array('keys' => 'Druplicon'); $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertText($user->getDisplayNameTruncated(), 'Basic page node displays author name when post settings are on.'); + $this->assertEscaped($user->getDisplayNameTruncated(), 'Basic page node displays author name when post settings are on.'); $this->assertText(format_date($node->getChangedTime(), 'short'), 'Basic page node displays post date when post settings are on.'); // Check that with post settings turned off the user and changed date diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 5de385c..f54f23d 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -383,7 +383,7 @@ public function getDisplayName() { public function getDisplayNameTruncated() { $name = $this->getDisplayName(); if (Unicode::strlen($name) > 20) { - $name = Unicode::truncate($name, 15, FALSE, TRUE); + $name = Unicode::truncate((string) $name, 15, FALSE, TRUE); } return $name; } diff --git a/core/modules/user/src/Tests/UserAdminTest.php b/core/modules/user/src/Tests/UserAdminTest.php index bd2a12d..ed88f91 100644 --- a/core/modules/user/src/Tests/UserAdminTest.php +++ b/core/modules/user/src/Tests/UserAdminTest.php @@ -178,7 +178,7 @@ function testNotificationEmailAddress() { $edit['mail'] = $edit['name'] . '@example.com'; $this->drupalPostForm('user/register', $edit, t('Create new account')); $user = user_load_by_name($edit['name']); - $subject = 'Account details for ' . $user->getDisplayName() . ' at ' . $system->get('name') . ' (pending admin approval)'; + $subject = strip_tags('Account details for ' . $user->getDisplayName() . ' at ' . $system->get('name') . ' (pending admin approval)'); // Ensure that admin notification mail is sent to the configured // Notification Email address. $admin_mail = $this->drupalGetMails(array(