jeudi 29 mars 2018

Trying to get Laravel Dusk to behave with sqlite database

I'm trying to get Laravel Dusk to play nicely with an App i'm trying to test.

At the moment I can write to a test sqlite database but when I try to test a login form following the guidance it appears the details in the development database are being used instead.

Here's my test:

class LoginTest extends DuskTestCase
{

private $user;

use DatabaseMigrations;

public function setUp()
{
    parent::setUp();

    $this->user = factory(User::class)->create(['password' => bcrypt('secret')]);

}

/**
 * A Dusk test example.
 *
 * @return void
 * @throws \Exception
 * @throws \Throwable
 */
public function test_user_can_log_in()
{

    $this->browse(function (Browser $browser) {

        $browser->visit('/login')
            ->assertSee('Members sign in')
            ->type('email', $this->user->email)
            ->type('password', 'secret')
            ->driver->executeScript('window.scrollTo(0, 500);');

        $browser->press('Sign in')
            ->assertPathIs('/home');
    });
}
}

This test fails authentication as the user I've just created doesn't exist in the development Mysql database it is reading from.

I am able to see the user I've just created in the sqlite database and can query that user exists

What am I doing wrong? Does Laravel Auth do something to override the connections?

Thank you

Aucun commentaire:

Enregistrer un commentaire