diff --git a/core/modules/user/src/Tests/UserPictureTest.php b/core/modules/user/src/Tests/UserPictureTest.php index c506d41..2ddfb44 100755 --- a/core/modules/user/src/Tests/UserPictureTest.php +++ b/core/modules/user/src/Tests/UserPictureTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Component\Utility\SafeMarkup; use Drupal\simpletest\WebTestBase; use Drupal\file\Entity\File; @@ -100,7 +101,9 @@ function testPictureOnNodeComment() { // Verify that the image is displayed on the user account page. $this->drupalGet('node/' . $node->id()); $this->assertRaw(file_uri_target($file->getFileUri()), 'User picture found on node page.'); - $this->assertRaw('alt="' . t('Profile picture for user @username', ['@username' => $this->webUser->getUsername()]) . '"'); + $alt_text = SafeMarkup::format('Profile picture for user @username', ['@username' => $this->webUser->getUsername()]); + $elements = $this->cssSelect('.node__meta .field-user--user-picture img[alt="' . $alt_text . '"]'); + $this->assertEqual(count($elements), 1, 'Found alt text for user image on user account page.'); // Enable user pictures on comments, instead of nodes. $this->config('system.theme.global') @@ -113,7 +116,9 @@ function testPictureOnNodeComment() { ); $this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, t('Save')); $this->assertRaw(file_uri_target($file->getFileUri()), 'User picture found on comment.'); - $this->assertRaw('alt="' . t('Profile picture for user @username', ['@username' => $this->webUser->getUsername()]) . '"'); + $alt_text = SafeMarkup::format('Profile picture for user @username', ['@username' => $this->webUser->getUsername()]); + $elements = $this->cssSelect('.comment__meta .field-user--user-picture img[alt="' . $alt_text . '"]'); + $this->assertEqual(count($elements), 1, 'Found alt text for user image on comment page.'); // Disable user pictures on comments and nodes. $this->config('system.theme.global')