Laravel 5 app always using 'testing' environment configuration

Additional points I've just had to use to get tests running on sqlite, while the main app normally defaults to mysql:

Add something like this to phpunit.xml, as explained by craig.michael.morris:

<env name="DB_DRIVER" value="sqlite"/>

And this change to config/database.php

'default' => env('DB_DRIVER', 'mysql'),

And in the 'sqlite' section of config/database.php

'database' => ':memory:',

Laravel 5 doesn't cascade config files correctly anymore so your testing config file is overriding anything you have in your local config file.

Now you aren't supposed to have any subfolders for each environment, but rather set configuration settings inside the .env file in the root folder.

This file isn't checked in to the repo to ensure that nothing sensitive is checked into the repo. You should have a separate .env file for each environment your application is living.

TESTING

For php unit (functional) you can set env variables in the phpunit.xml file e.g..

<php>
    <env name="APP_ENV" value="testing"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="SESSION_DRIVER" value="array"/>
</php>

For behat (acceptance) testing the Laracasts Laravel Behat extension allows you to create a .env.behat file to change the environment variables.

For phpspec (unit) testing well the environment shouldn't matter as your testing individual methods in isolation and mock everything else.

For selenium (integration / system / e2e) testing the environment variables should come from the .env file on the server wherever you are doing this testing.