5 years ago

How to specify a testing database in Laravel 5?

Posted 5 years ago by mkudenko

I'm trying to write unit tests for my models and controllers. I know that Laravel sets the environment to "testing" by default, but I can't figure out where to specify the test database name so it's not version controlled.

I can change the database name in phpunit.xml, but that file is commited:

<env name="DB_DATABASE" value="test_db"/>

Ideally, I'd like it to work like the .env file. .env.test maybe, that is used for unit testing?

Any help and advice are appreciated.

Please sign in or create an account to participate in this conversation.