Following setup ensures that testing framework (PHPUnit) uses :memory:
database.
config/database.php
'connections' => [
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
.
.
.
./phpunit.xml
.
.
.
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_URL" value="http://example.dev"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="sqlite_testing"/>
</php>
</phpunit>