Ad

Login Test - Laravel

- 1 answer

I'm new to laravel and was attempting to test a user login but since I've started using in memory sqlite I've been having problems. My Code:

$user = factory(App\User::class)->create
    ([
        'email'=>'[email protected]',
        'password'=>'passwordtest'
    ]);

    $this->visit('/auth/login')
        ->type('[email protected]', 'email')
        ->type('passwordtest', 'password')
        ->press('Login')
        ->seePageIs('/home');

When I run this code it never makes it past the login page. Anyone know what I'm doing wrong?

Ad

Answer

You need to encrypt the password:

$user = factory(App\User::class)->create
([
    'email'=>'[email protected]',
    'password'=>bcrypt('passwordtest')
]);
Ad
source: stackoverflow.com
Ad