function MenuRouterTest::testAuthUserUserLogin

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testAuthUserUserLogin()
  2. 8.9.x core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testAuthUserUserLogin()
  3. 11.x core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testAuthUserUserLogin()

Tests authenticated user login redirects.

An authenticated user hitting 'user/login' should be redirected to 'user', and 'user/register' should be redirected to the user edit page.

File

core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php, line 232

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testAuthUserUserLogin() : void {
    $web_user = $this->drupalCreateUser([]);
    $this->drupalLogin($web_user);
    $this->drupalGet('user/login');
    // Check that we got to 'user'.
    $this->assertSession()
        ->addressEquals($this->loggedInUser
        ->toUrl('canonical'));
    // user/register should redirect to user/UID/edit.
    $this->drupalGet('user/register');
    $this->assertSession()
        ->addressEquals($this->loggedInUser
        ->toUrl('edit-form'));
}

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