Created
May 23, 2019 15:26
-
-
Save bfodeke/4fc790b6ea27e7a500bf6b37e6872933 to your computer and use it in GitHub Desktop.
Behat: Logging in to accounts via email or username using drush
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Given I log in as :name | |
*/ | |
public function iLogInAs($name) { | |
$domain = $this->getMinkParameter('base_url'); | |
// Pass base url to drush command. | |
$uli = $this->getDriver('drush')->drush('uli', array( | |
"'" . $name . "'", | |
"--browser=0", | |
"--uri=$domain", | |
)); | |
// Trim EOL characters. | |
$uli = trim($uli); | |
$this->getSession()->visit($uli); | |
} | |
/** | |
* @Given I log in as user with :name email | |
*/ | |
public function iLogInAsUserWithEmail($email) { | |
$domain = $this->getMinkParameter('base_url'); | |
// Pass base url to drush command. | |
$uli = $this->getDriver('drush')->drush('uli', array( | |
"--mail='$email'", | |
"--browser=0", | |
"--uri=$domain", | |
)); | |
// Trim EOL characters. | |
$uli = trim($uli); | |
$this->getSession()->visit($uli); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment