function UserLoginTest::testLoginCacheTagsAndDestination

Same name and namespace in other branches
  1. 8.9.x core/modules/user/tests/src/Functional/UserLoginTest.php \Drupal\Tests\user\Functional\UserLoginTest::testLoginCacheTagsAndDestination()
  2. 10 core/modules/user/tests/src/Functional/UserLoginTest.php \Drupal\Tests\user\Functional\UserLoginTest::testLoginCacheTagsAndDestination()
  3. 11.x core/modules/user/tests/src/Functional/UserLoginTest.php \Drupal\Tests\user\Functional\UserLoginTest::testLoginCacheTagsAndDestination()

Tests login with destination.

File

core/modules/user/tests/src/Functional/UserLoginTest.php, line 35

Class

UserLoginTest
Ensure that login works as expected.

Namespace

Drupal\Tests\user\Functional

Code

public function testLoginCacheTagsAndDestination() {
    $this->drupalGet('user/login');
    // The user login form says "Enter your <site name> username.", hence it
    // depends on config:system.site, and its cache tags should be present.
    $this->assertSession()
        ->responseHeaderContains('X-Drupal-Cache-Tags', 'config:system.site');
    $user = $this->drupalCreateUser([]);
    $this->drupalGet('user/login', [
        'query' => [
            'destination' => 'foo',
        ],
    ]);
    $edit = [
        'name' => $user->getAccountName(),
        'pass' => $user->passRaw,
    ];
    $this->submitForm($edit, 'Log in');
    $this->assertSession()
        ->addressEquals('foo');
}

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