Skip to content

Instantly share code, notes, and snippets.

@JoseCage
Last active November 24, 2016 12:33
Show Gist options
  • Save JoseCage/d0c39efb7e31cb354b44ebc1945ab3ed to your computer and use it in GitHub Desktop.
Save JoseCage/d0c39efb7e31cb354b44ebc1945ab3ed to your computer and use it in GitHub Desktop.
PHPUnit test database environment for Laravel
TEST_DB_HOST=localhost # or 127.0.0.1
TEST_DB_DATABASE=my_app
TEST_DB_USERNAME=root
DBT_PASSWORD= # Put you password here if required or leave blank..
#File located at config/database.php
//This script must be inside connections line.
...
'my_app_test' => [
'driver' => 'mysql',
'host' => env('TEST_DB_HOST', 'localhost'),
'database' => env('TEST_DB_DATABASE', 'test'),
'username' => env('TEST_DB_USERNAME', 'root'),
'password' => env('TEST_DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
...
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="my_app_test"/>
<env name="DB_DATABASE" value="my_app"/>
<!--PS: If you prefer to use the same DB defined in .env file just delete the DB_DATABASE line -->
</php>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment