18. Oct 2022 |

Laravel – run PHPUnit test on separate database (with phpStorm)

In phpStorm see Settings -> PHP -> Test Frameworks -> Test Runner. Check if you have default configuration file phpunit.xml checked. No need to change anything in this file.

Create .env.testing and copy whole DB_ block from .env (not just parts that are different). Change values to your test database values.

Then run php artisan config:clear which will clear configuration cache.

Everything should work 🙂

I spent several hours figuring it out. Hopefully you don’t.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.