Overwrite APP_ENV in PHPUnit

Overwrite APP_ENV in PHPUnit
Photo by R.D. Smith / Unsplash

Important when you're using something like Docker where you inject the env variables directly into the environment rather than just pulling them from a .env file with a PHP dotenv component.

Make sure to use force="true" in your phpunit.xml.dist like:

<phpunit ...>
    <env name="APP_ENV" value="test" force="true" />