I just encountered the following scenario...
Imagine you use a MySQL database for your browser but would prefer a SQLite database for your testing with Dusk. I think that's quite a common case, or could be. So you might do something like this:
in your .env
file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
in your .env.dusk.local
file:
DB_CONNECTION=sqlite
One might think this would work, but the problem is that the environment files are merged when running Dusk. In other words, the Dusk configuration will become:
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
And if you have a look at the default Laravel config for SQLite:
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
you will notice that it will try to get the homestead
SQLite database in your project root, which does not exist - and obviously, your test will fail with errors like: users table not found
for example, if you are running the default migrations.
Aucun commentaire:
Enregistrer un commentaire