How to specify a testing database in Laravel 5?

Posted 3 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.