I am trying to use sqlite db for testing since I do not want to touch my actual database:
In my unit.suite.yml file:
class_name: UnitTester modules: enabled: [Asserts, UnitHelper] config: Db: dsn: 'sqlite:app/tests/_data/testdb.sqlite' user: '' password: '' dump: app/tests/_data/dump.sql
In my TestCase.php file, I have a function that resets and migrates, and db seeds for testing:
Artisan::call('migrate:reset'); Artisan::call('migrate'); Artisan::call('db:seed');
I also added sqlite settings to app / config / testing / database.php:
<?php // Codeception testing environment uses SQLITE return [ 'default' => 'sqlite', 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => 'app/tests/_data/testdb.sqlite', 'prefix' => '' ], ] ];
I can verify that the database.php file is being read, but something still does not allow sqlite to be used, and I still end up shunting my REAL database (MySQL). How to force Laravel / Codeception to use my test db?
laravel codeception
Joel Joel Binks
source share