To answer my own question, these can be set using the phpunit.xml file:
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_DRIVER" value="sqlite"/>
</php>
Like many, I have one machine that I develop my applications on and also use for testing. I'm using a MySQL database for development (and will be doing for production), but for my tests, I want to use an SQLite database.
I know that PHPUnit will switch the environment to 'testing', but how can I tell it which configuration options to use?
In config/database.php I have set the default database connection name to:
'default' => env('DB_DRIVER', 'mysql'),
and in my .env file, I have:
APP_ENV=local
APP_DEBUG=true
DB_DRIVER=mysql
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
So, that's the local environment taken care of.
When PHPUnit runs, and it switches the env to testing, I want it to use SQLite.
I want to have a second environment config file for testing, like so:
APP_ENV=testing
APP_DEBUG=true
DB_DRIVER=sqlite
How can I create this file, and define the DB_DRIVER? It looks like .env.testing files are no longer supported, so I'm wondering how I can have a different set of config options for different environments on a single machine.
To answer my own question, these can be set using the phpunit.xml file:
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_DRIVER" value="sqlite"/>
</php>
Please or to participate in this conversation.