Question: 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

Answer: 
After researching the stack trace for a long time, I found the problem! All the same, the cache turned out to be.
The config cache needs to be cleared ('php artisan config: clear') because Laravel stores the old connection name.

I just tried to clear the cache ("php artisan cache: clear") or clear and cache the configuration at the same time ("php artisan config: cache"). This is why it didn't work.

By the way, there was a problem on [GitHub](https://github.com/laravel/framework/issues/13374) about this. But I couldn't find it because I didn't know what the problem was. There is a little life hack to avoid clearing the config cache every time before running tests if you cache your config and routes.

Thanks @P.K.Tharindu for the help. You were close to the answer.
As per how you have setup your database connections, you should be defining `DB_DATABASE_TESTING=testing_db_name` not `DB_DATABASE=testing_db_name`.