Posted by Shailesh Davara on January 28, 2016 | 2 Minute Read
Laravel comes with many good features. One of the best feature, I liked a lot is ‘testing’ inside a framework. We don’t need to add any new package. It comes out of the box. There are few points for a good testing likes of having a separate database, run migrations and impersonate development environment etc. Laravel allows you to cover all those points in your testcases.
From laravel 5, it introduces .env file. That is a plain text file with the key value pair. We can have different .env file inside an application for the different environment. When we run testcases, laravel runs it under ‘testing’ environment. To alter testing environment variables, we can edit ‘phpunit.xml’ file in the root folder of our application.
Below is my ‘phpunit.xml’ file.
You may have noticed that I’ve listed few environment variables in ‘php’ section. The aplication will try to find all environment variables in this file, if they don’t find, it will try to get from .env file of the application. For more configuration options, you can visit unit test documents.