I am running unit tests and all the tests passed but when I run php artisan config:cache, running the test again makes most of my test failed and I checked my database, the tables were gone.
Why does this happen and how do I fix this?
Tried to run php artisan migrate and run the phpunit test again and the tables are removed again.
It will work as you config isnt cached. It shouldnt be. If the config is cached you disable checking environment variables, causing testing fail.
Most likely your tests are set to cleanup after themself. When you cached your config, your testing didnt know to use the testing database (as environment is disabled), and it therefor use your "real" database.
@nickywan123 Ok. Well something in your tests is changing your tables :) Without looking over your files it will be hard to say what. But anyways. Just make sure you dont cache config again, and all is good :)