Skip to content

Instantly share code, notes, and snippets.

@alnutile
Created November 3, 2016 19:47
Show Gist options
  • Save alnutile/4cef8b219877afa8acd0c2c6d5202c04 to your computer and use it in GitHub Desktop.
Save alnutile/4cef8b219877afa8acd0c2c6d5202c04 to your computer and use it in GitHub Desktop.
<?php
trait LogInAs
{
/**
* @Given I log in as behat user
*/
public function logInAsBehat()
{
$user = '[email protected]';
$pass = env('BEHAT_PASSWORD');
$this->loginForm($user, $pass);
}
/**
* @Given I log in as admin
*/
public function logInAsAdmin()
{
$user = '[email protected]';
$pass = env('ADMIN_PASSWORD');
$this->loginForm($user, $pass);
}
public function loginForm($user, $pass)
{
/**
* if for any reason we are logged in still
*/
$this->visit('/logout');
sleep(1);
$this->visit('/login');
sleep(2);
$this->fillField('email', $user);
$this->fillField('password', $pass);
$this->pressButton('Login');
sleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment