You are here

function UserLoginTest::testLoginCacheTagsAndDestination in Zircon Profile 8

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

Tests login with destination.

File

core/modules/user/src/Tests/UserLoginTest.php, line 23
Contains \Drupal\user\Tests\UserLoginTest.

Class

UserLoginTest
Ensure that login works as expected.

Namespace

Drupal\user\Tests

Code

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
    ->assertCacheTag('config:system.site');
  $user = $this
    ->drupalCreateUser(array());
  $this
    ->drupalGet('user/login', array(
    'query' => array(
      'destination' => 'foo',
    ),
  ));
  $edit = array(
    'name' => $user
      ->getUserName(),
    'pass' => $user->pass_raw,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Log in'));
  $this
    ->assertUrl('foo', [], 'Redirected to the correct URL');
}