You are here

public function VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

Same name and namespace in other branches
  1. 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
  2. 8.5 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
  3. 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
  4. 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
  5. 9.0.x tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()

Authenticate a user with a given username and password on the spot.

Varbase Context #varbase.

Example: I am a logged in user with the username "testing" and password "testing user password"

@Given /^I am a logged in user with (?:|the )username "(?P<username>[^"]*)" and password "(?P<password>[^"]*)"$/

File

tests/features/bootstrap/VarbaseContext.php, line 108

Class

VarbaseContext
Defines application features from the specific context.

Code

public function iAmLoggedInUserWithTheUsernameAndPassword($username, $password) {

  // Logout if I am logged in.
  if ($this
    ->loggedIn()) {
    $this
      ->logout();
  }

  // Login with the.
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->getSession()
    ->visit($this
    ->locatePath('/user/login'));
  $page
    ->fillField('edit-name', $username);
  $page
    ->fillField('edit-pass', $password);
  $submit = $page
    ->findButton('op');
  $submit
    ->click();
}