AlessioGiacobbe's avatar

./artisan test wipes both main and tests db

hello! i'm running laravel 12 and testing with PHPunit, i have configured it like so in my phpunit.xml:

        <env name="DB_CONNECTION" value="pgsql_testing"/>

and in my database.php config:

'pgsql_testing' => [
            'driver' => 'pgsql',
            'database' => env('DB_DATABASE', '') . '_test',

i use some tests with the RefreshDatabase trait, but when i run my tests my main db gets wiped together with the tests database. i don't understand what i am missing. thanks.

1 like
3 replies
vincent15000's avatar

What's the value for <env name="DB_DATABASE" value="..."/> ?

1 like
vincent15000's avatar
Level 63

It should work.

I already had a similar problem, I have solved it by clearing the cache.

1 like

Please or to participate in this conversation.