public function TestSubContext::iLogInWithTheOneTimeLoginUrl in Drupal Commons 7.3
@Given I log in with the One Time Login Url
File
- tests/
steps/ commons_test.behat.inc, line 338 - Provide Behat step-definitions for generic Commons tests.
Class
Code
public function iLogInWithTheOneTimeLoginUrl() {
if ($this
->loggedIn()) {
$this
->logOut();
}
$random = new Random();
// Create user (and project)
$user = (object) array(
'name' => $random
->name(8),
'pass' => $random
->name(16),
'role' => 'authenticated user',
);
$user->mail = "{$user->name}@example.com";
// Create a new user.
$this
->getDriver()
->userCreate($user);
$this->users[$user->name] = $this->user = $user;
$base_url = rtrim($this
->locatePath('/'), '/');
$login_link = $this
->getDriver('drush')
->drush('uli', array(
"'{$user->name}'",
'--browser=0',
"--uri={$base_url}",
));
// Trim EOL characters. Required or else visiting the link won't work.
$login_link = trim($login_link);
$login_link = str_replace("/login", '', $login_link);
$this
->getSession()
->visit($this
->locatePath($login_link));
return TRUE;
}