jeudi 21 septembre 2017

Laravel write testcases for login

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, $module)
{
    if(!Session::has($module))//$modules are user,admin
        return redirect('/'.$module.'/login');
    return $next($request);
}

Aucun commentaire:

Enregistrer un commentaire