You are here

function UserAccountLinksTest::testAccountPageTitles in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/UserAccountLinksTest.php \Drupal\user\Tests\UserAccountLinksTest::testAccountPageTitles()

Tests page title is set correctly on user account tabs.

File

core/modules/user/src/Tests/UserAccountLinksTest.php, line 118
Contains \Drupal\user\Tests\UserAccountLinksTest.

Class

UserAccountLinksTest
Tests user-account links.

Namespace

Drupal\user\Tests

Code

function testAccountPageTitles() {

  // Default page titles are suffixed with the site name - Drupal.
  $title_suffix = ' | Drupal';
  $this
    ->drupalGet('user');
  $this
    ->assertTitle('Log in' . $title_suffix, "Page title of /user is 'Log in'");
  $this
    ->drupalGet('user/login');
  $this
    ->assertTitle('Log in' . $title_suffix, "Page title of /user/login is 'Log in'");
  $this
    ->drupalGet('user/register');
  $this
    ->assertTitle('Create new account' . $title_suffix, "Page title of /user/register is 'Create new account' for anonymous users.");
  $this
    ->drupalGet('user/password');
  $this
    ->assertTitle('Reset your password' . $title_suffix, "Page title of /user/register is 'Reset your password' for anonymous users.");

  // Check the page title for registered users is "My Account" in menus.
  $this
    ->drupalLogin($this
    ->drupalCreateUser());

  // After login, the client is redirected to /user.
  $this
    ->assertLink(t('My account'), 0, "Page title of /user is 'My Account' in menus for registered users");
  $this
    ->assertLinkByHref(\Drupal::urlGenerator()
    ->generate('user.page'), 0);
}