I have a Laravel 5 app with two environments and two configurations: testing (for PHPUnit configuration, in-memory db) and local (my development configuration).
Even whe
1) open the config file database.php
and add the following inside the 'connections' => [
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
this in memory sqlite will be used for your testing
2) open the .env
file and make sure it has the following:
DB_CONNECTION=mysql
3) open phpunit.xml
and add the following inside the
tag:
here’s where you can add all the testing related env variables
4) in your tests were you use a database connection use the Database Migration Trait:
use DatabaseMigrations;
for more details about the DatabaseMigrations refer to the documentation https://laravel.com/docs/5.1/testing#resetting-the-database-after-each-test