Ad
Laravel 5 : Use Different Database For Testing And Local
How does one change database for development and testing on local system without editing the .env
file each time?
I have found it quite inconvenient to practice TDD because of this.
Is it possible for a Laravel application to differentiate between normal development and testing so that it can choose the appropriate database?
Ad
Answer
Create a testing database configuration in Laravel
Edit the config\database.php
file and add a testing
- array into the connections
array:
'connections' => [
'testing' => [
'driver' => env('DB_TEST_DRIVER'),
// more details on your testing database
]
]
Then add the necessary variables to your .env
-file.
Edit PHPUnit configuration
Open your phpunit.xml
-file and add the following within your <php>
-tag:
<env name="DB_CONNECTION" value="testing"/>
Now PHPUnit will run with the tests on the database you defined in the testing
- array.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad