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() { ...@@ -273,7 +273,7 @@ public function userPage() {
* NULL. * NULL.
*/ */
public function userTitle(UserInterface $user = 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 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Tests\user\Functional; namespace Drupal\Tests\user\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
...@@ -29,9 +30,15 @@ public function testUserEdit() { ...@@ -29,9 +30,15 @@ public function testUserEdit() {
// is the raw value and not a formatted one. // is the raw value and not a formatted one.
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE); \Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
\Drupal::service('module_installer')->install(['user_hooks_test']); \Drupal::service('module_installer')->install(['user_hooks_test']);
Cache::invalidateTags(['rendered']);
$this->drupalGet('user/' . $user1->id() . '/edit'); $this->drupalGet('user/' . $user1->id() . '/edit');
$this->assertFieldByName('name', $user1->getAccountName()); $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. // Check that filling out a single password field does not validate.
$edit = []; $edit = [];
$edit['pass[pass1]'] = ''; $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