-
-
Save JoseCage/d0c39efb7e31cb354b44ebc1945ab3ed to your computer and use it in GitHub Desktop.
PHPUnit test database environment for Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, | |
], | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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