Unverified Commit bfb8a7da authored by alexpott's avatar alexpott

Issue #2746065 by Berdir, yogeshmpawar, hlykos, xeM8VfDh: Profile page's...

Issue #2746065 by Berdir, yogeshmpawar, hlykos, xeM8VfDh: Profile page's title/heading does not fulfill hook_user_format_name_alter
parent 1950bd5f
......@@ -273,7 +273,7 @@ public function userPage() {
* NULL.
*/
public function userTitle(UserInterface $user = NULL) {
return $user ? ['#markup' => $user->getUsername(), '#allowed_tags' => Xss::getHtmlTagList()] : '';
return $user ? ['#markup' => $user->getDisplayName(), '#allowed_tags' => Xss::getHtmlTagList()] : '';
}
/**
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -29,9 +30,15 @@ public function testUserEdit() {
// is the raw value and not a formatted one.
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
\Drupal::service('module_installer')->install(['user_hooks_test']);
Cache::invalidateTags(['rendered']);
$this->drupalGet('user/' . $user1->id() . '/edit');
$this->assertFieldByName('name', $user1->getAccountName());
// Ensure the formatted name is displayed when expected.
$this->drupalGet('user/' . $user1->id());
$this->assertSession()->responseContains($user1->getDisplayName());
$this->assertSession()->titleEquals(strip_tags($user1->getDisplayName()) . ' | Drupal');
// Check that filling out a single password field does not validate.
$edit = [];
$edit['pass[pass1]'] = '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment