You are here

public function QuickStartTestBase::formLogin in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php \Drupal\BuildTests\QuickStart\QuickStartTestBase::formLogin()

Helper that uses Drupal's user/login form to log in.

Parameters

string $username: Username.

string $password: Password.

string $working_dir: (optional) A working directory within which to login. Defaults to the workspace directory.

1 call to QuickStartTestBase::formLogin()
HtRouterTest::testHtRouter in core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php
@covers ::instantiateServer

File

core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php, line 56

Class

QuickStartTestBase
Helper methods for using the quickstart feature of Drupal.

Namespace

Drupal\BuildTests\QuickStart

Code

public function formLogin($username, $password, $working_dir = NULL) {
  $this
    ->visit('/user/login', $working_dir);
  $assert = $this
    ->getMink()
    ->assertSession();
  $assert
    ->statusCodeEquals(200);
  $assert
    ->fieldExists('edit-name')
    ->setValue($username);
  $assert
    ->fieldExists('edit-pass')
    ->setValue($password);
  $session = $this
    ->getMink()
    ->getSession();
  $session
    ->getPage()
    ->findButton('Log in')
    ->submit();
}