I can successfully seed records to my normal database. Now I am focusing on tests and the first step is to add ‘test database’.
How can I seed to that specific database other than the normal database?
`<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="testing"/>
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>`
Above is my phpunit configuration file, I also have env.testing file holding my testing configurations.
I already have daatabase called database_testing
which is up
2
Answers
Copy your
.env
and rename to.env.testing
. Change:Inside the new
.env.testing
file.on your .env file, change the name of database which you want to launch seed again:
if not in local environment, change also the name of actual environment :
save modifications and enter command to allow use new env data :