I have to write a test case for my login functionality. I wrote like this
public function testBasicExample()
{
$this->visit('/user/login-with-email')
->type('abc@xyz.com', 'email')
->type('xxxxxxx', 'password')
->press('LOG IN')
->seePageIs('/user/dashboard');
}
I am running it from console using the command phpunit. But it gives me error as
Did not land on expected page [http://ift.tt/2fCQ9ip]
I used session for authenticating the users inside the Authenticate Middleware as
public function handle($request, Closure $next, $parentmodule)
{
$userRoleFlag = false;
if (Auth::check() || Session::has('admin') || Session::has('user')) {
if ($parentmodule == "admin") {
if (Session::has('admin')) {
$userRoleFlag = true;
}
if (!$userRoleFlag) {
return redirect('/admin/login');
}
} else if ($parentmodule == "user") {
if (Session::has('user')) {
$userRoleFlag = true;
}
if (!$userRoleFlag) {
return redirect('/user/login');
}
}
return $next($request);
}
else{
return redirect('/user/login');
}
}
Aucun commentaire:
Enregistrer un commentaire