Created
September 18, 2016 15:11
-
-
Save dimitri-koenig/43b543044359b67faeccb63bca97f207 to your computer and use it in GitHub Desktop.
Behat Laravel Login As
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
<?php | |
function iAmLoggedIn() | |
{ | |
// Destroy the previous session | |
if (Session::isStarted()) | |
{ | |
Session::regenerate(true); | |
} | |
else | |
{ | |
Session::start(); | |
} | |
Auth::login($this->user); | |
PHPUnit::assertTrue(Auth::check(), 'User is not logged in'); | |
Session::save(); | |
// Get the session identifier for the cookie | |
$encryptedSessionId = Crypt::encrypt(Session::getId()); | |
$cookieName = Session::getName(); | |
// Set the cookie | |
$minkSession = $this->getSession(); | |
$minkSession->setCookie($cookieName, $encryptedSessionId); | |
$this->reload(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment