I think this will help you get started
1. Override Database settings for testing only
Inside app/config/testing create a new file named database.php and inside it place:
return array(
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'TEST_DB_NAME', // Create also the Database
'username' => 'USERNAME',
'password' => 'PASSWORD',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
)
)
);
This database will bee used only for testing purposes.
2. Add this info to codeception.yml also
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=TEST_DB_NAME'
user: 'USERNAME'
password: 'PASSWORD'
dump: app/tests/_data/dump.sql
3. Migrate and seed the testing database
php artisan migrate --seed --env="testing"
4. To clean up the database
php artisan migrate:reset --env="testing"