if you are using laravel above 5.4,
DatabaseMigrations trait not longer exists,
use RefreshDatabase instead..
I started a fresh Laravel project. I added a new sqlite_testing database connection and use it in the phpunit.xml. I want to use the DatabaseTransactions and DatabaseMigrations traits provided by Laravel in my tests. If I use DatabaseTransactions my database is not migrated and seeded. If I use the DatabaseMigrations, the sqlite database is not used, but my local MySQL db is used instead (which deletes all my data).
My setup below:
// database.php
'connections' => [
// some connections...
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
//.....
// phpunit.xml
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite_testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
I googled a lot and all answers I found pointed to this solution, but for some reason it's not working for me.
try to clear cache, then clear config
php artisan cache:clear
php artisan config:clear
then try again..
Please or to participate in this conversation.