public function TestSubContext::iLogInWithTheOneTimeLoginUrl in Panopoly 8.2
Same name and namespace in other branches
- 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::iLogInWithTheOneTimeLoginUrl()
Logs in with the one time login URL.
@Given I log in with the One Time Login Url
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 679 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public function iLogInWithTheOneTimeLoginUrl() {
if ($this
->loggedIn()) {
$this
->logOut();
}
$random = new Random();
// Create user (and project)
$user = (object) [
'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', [
"'{$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;
}