Configure PHPUnit to use newly created database connection for testing
MODIFY
config/database.php
config/database.php
@@ -54,6 +54,21 @@ return [
'engine' => null,
],
+ 'testing' => [
+ 'driver' => 'mysql',
+ 'host' => env('DB_HOST', '127.0.0.1'),
+ 'port' => env('DB_PORT', '3306'),
+ 'database' => env('DB_DATABASE', 'forge') . '_testing',
+ 'username' => env('DB_USERNAME', 'forge'),
+ 'password' => env('DB_PASSWORD', ''),
+ 'unix_socket' => env('DB_SOCKET', ''),
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'prefix' => '',
+ 'strict' => false,
+ 'engine' => null,
+ ],
+
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),

MODIFY
phpunit.xml
phpunit.xml
</filter>
<php>
<env name="APP_ENV" value="testing"/>
+ <env name="DB_CONNECTION" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>

Configure PHPUnit to use newly created database connection for testing