I am using Laravel 5.3.22 and want to do unit testing of my application using a sqlite database in memory that migrates / rolls back for each test, as said here . This is the connections section of my config.php database:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), ... ], 'testing' => [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ],
This is the phpunit env config:
<php> <env name="APP_ENV" value="testing"/> <env name="CACHE_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/> <env name="QUEUE_DRIVER" value="sync"/> <env name="DB_CONNECTION" value="testing"/> </php>
The phpunit configuration implies that laravel shoud uses the "test" sqlite connection for testing, but it does not matter and continues with the main mysql connection. This is not an option, I have a large and complex scheme, and it cannot be used for unit testing with MySQL. How do I proceed? I canβt scoff at the query creator because I need to validate the results on it.
source share