Commit 84e06064 authored by catch's avatar catch

Issue #2717805 by JeroenT, dawehner: Use display name instead of username

parent 96ed8ac5
......@@ -121,9 +121,9 @@ public function form(array $form, FormStateInterface $form_state) {
// prevent the impersonation of other users.
else {
$form['name']['#type'] = 'item';
$form['name']['#value'] = $user->getUsername();
$form['name']['#value'] = $user->getDisplayName();
$form['name']['#required'] = FALSE;
$form['name']['#plain_text'] = $user->getUsername();
$form['name']['#plain_text'] = $user->getDisplayName();
$form['mail']['#type'] = 'item';
$form['mail']['#value'] = $user->getEmail();
......
......@@ -77,12 +77,12 @@ function testSendPersonalContactMessage() {
$variables = array(
'@site-name' => $this->config('system.site')->get('name'),
'@subject' => $message['subject[0][value]'],
'@recipient-name' => $this->contactUser->getUsername(),
'@recipient-name' => $this->contactUser->getDisplayName(),
);
$subject = PlainTextOutput::renderFromHtml(t('[@site-name] @subject', $variables));
$this->assertEqual($mail['subject'], $subject, 'Subject is in sent message.');
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['@recipient-name']) !== FALSE, 'Recipient name is in sent message.');
$this->assertTrue(strpos($mail['body'], $this->webUser->getUsername()) !== FALSE, 'Sender name is in sent message.');
$this->assertTrue(strpos($mail['body'], $this->webUser->getDisplayName()) !== FALSE, 'Sender name is in sent message.');
$this->assertTrue(strpos($mail['body'], $message['message[0][value]']) !== FALSE, 'Message body is in sent message.');
// Check there was no problems raised during sending.
......@@ -109,7 +109,7 @@ function testPersonalContactAccess() {
$this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(200);
// Check the page title is properly displayed.
$this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getUsername())));
$this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getDisplayName())));
// Test denied access to admin user's own contact form.
$this->drupalLogout();
......
......@@ -299,7 +299,7 @@ protected function getMockSender($anonymous = TRUE, $mail_address = 'anonymous@d
->method('getEmail')
->willReturn($mail_address);
$sender->expects($this->any())
->method('getUsername')
->method('getDisplayName')
->willReturn('user');
// User ID 1 has special implications, use 3 instead.
$sender->expects($this->any())
......@@ -369,7 +369,7 @@ protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
->method('getEmail')
->willReturn('user2@drupal.org');
$recipient->expects($this->once())
->method('getUsername')
->method('getDisplayName')
->willReturn('user2');
$recipient->expects($this->once())
->method('getPreferredLangcode')
......
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