Try add this to your phpunit.xml
<env name="DB_CONNECTION" value="sqlite_testing"/>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys,
I am currently facing a strange problem, which happened to me for the first time after working with laravel for a year and a half now.
I have been doing TDD with PHPUnit for a quite some time now and I have always declared the configuration variables, which will be used by the test environment, in phpunit.xml like so:
....
<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_DEFAULT" value="sqlite_testing" />
</php>
....
However now these variables do not seem to take any effect. They are completely overridden by the ones, declared in the .env file. Because of this I was forced to populate the configuration files with ugly statements like this one (config/database.php):
'default' => $app->environment() == 'testing' ? 'sqlite_testing' : env('DB_CONNECTION', 'mysql'),
I am currently running Laravel 5.1 on the latest homestead. The problem is not from homestead in my opinion since I updated it a couple of days ago and the problem still occurs.
Does anyone know how to fix this annoying problem?
Update: I spent a lot of time searching if someone else had faced the same issue but unluckily could not find any information.
The problem is solved.
I am executing PHPUnit on Homestead trough PHPStorm. Somehow when running the testing suite, the configuration file phpunit.xml was not used by default. I had to define it explicitly in the PHPStorm settings.
Please or to participate in this conversation.