php - Laravel 5 : Use different database for testing and local -
how 1 change database development , testing on local system without editing .env
file each time?
i have found quite inconvenient practice tdd because of this.
is possible laravel application differentiate between normal development , testing can choose appropriate database?
create testing database configuration in laravel
edit config\database.php
file , add testing
-array connections
array:
'connections' = [ 'testing' = [ 'driver' => env('db_test_driver'), // more details on testing database ] ]
then add necessary variables .env
-file.
edit phpunit configuration
open phpunit.xml
-file , add following within <php>
-tag:
<env name="db_connection" value="testing"/>
now phpunit run tests on database defined in testing
-array.
Comments
Post a Comment