function UserAccountLinksTest::testAccountPageTitles

Same name in other branches
  1. 9 core/modules/user/tests/src/Functional/UserAccountLinksTest.php \Drupal\Tests\user\Functional\UserAccountLinksTest::testAccountPageTitles()
  2. 10 core/modules/user/tests/src/Functional/UserAccountLinksTest.php \Drupal\Tests\user\Functional\UserAccountLinksTest::testAccountPageTitles()
  3. 11.x core/modules/user/tests/src/Functional/UserAccountLinksTest.php \Drupal\Tests\user\Functional\UserAccountLinksTest::testAccountPageTitles()

Tests page title is set correctly on user account tabs.

File

core/modules/user/tests/src/Functional/UserAccountLinksTest.php, line 121

Class

UserAccountLinksTest
Tests user-account links.

Namespace

Drupal\Tests\user\Functional

Code

public function testAccountPageTitles() {
    // Default page titles are suffixed with the site name - Drupal.
    $title_suffix = ' | Drupal';
    $this->drupalGet('user');
    $this->assertTitle('Log in' . $title_suffix);
    $this->drupalGet('user/login');
    $this->assertTitle('Log in' . $title_suffix);
    $this->drupalGet('user/register');
    $this->assertTitle('Create new account' . $title_suffix);
    $this->drupalGet('user/password');
    $this->assertTitle('Reset your password' . $title_suffix);
    // 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->assertSession()
        ->linkExists(t('My account'), 0, "Page title of /user is 'My Account' in menus for registered users");
    $this->assertLinkByHref(\Drupal::urlGenerator()->generate('user.page'), 0);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.