Skip to content

Instantly share code, notes, and snippets.

@nedSaf
Last active August 29, 2015 14:09
Show Gist options
  • Save nedSaf/c4669b809d9f6be913f6 to your computer and use it in GitHub Desktop.
Save nedSaf/c4669b809d9f6be913f6 to your computer and use it in GitHub Desktop.
Behat login
<?php
/**
* Initializes context.
*
* Every scenario gets its own context object.
*
* @param array $parameters.
* Context parameters (set them up through behat.yml or behat.local.yml).
*/
public function __construct(array $parameters) {
if (!empty($parameters['drupal_users'])) {
$this->drupal_users = $parameters['drupal_users'];
}
}
/**
* Authenticates a user with password from configuration.
*
* @Given /^I am logged in as user "([^"]*)"$/
*/
public function iAmLoggedInAsUser($username) {
$this->user = new stdClass();
$this->user->name = $username;
$this->user->pass = $this->drupal_users[$username];
$this->login();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment