jeudi 1 octobre 2020

Laravel. Tests clear the active DB

The tables in my active DB are empty after tests.

I have the test environment variable DB_CONNECTION=mysql_testing. When I run my tests and do dd(env('DB_CONNECTION')) - everything is fine. I see 'mysql_testing'.

But when I write dd( \DB::connection()->getDatabaseName()) I see the wrong DB name(for example 'db_name', but it should be 'testing_db_name') . It is the name of the active DB. It's not the config cache. Everything is fine there. I see the correct database name for the 'mysql_testing' connection. I even tried to set the test environment variable DB_DATABASE=testing_db_name.

Stack: Laravel 7.28.3, PHPUnit 8.5.8

Aucun commentaire:

Enregistrer un commentaire