You are here

public function MenuRouterTest::testAuthUserUserLogin in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testAuthUserUserLogin()

Tests that an authenticated user hitting 'user/login' gets redirected to 'user' and 'user/register' gets redirected to the user edit page.

File

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

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testAuthUserUserLogin() {
  $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'));
}