I'm using Lumen 8.
and I want to use the configuration inside .env.testing
but it always read the configuration inside .env
tests/TestCase.php
<?php
use Dotenv\Dotenv;
abstract class TestCase extends Tests\Utilities\UnitTest\Testing\TestCase
{
public static function setUpBeforeClass(): void
{
Dotenv::createImmutable(dirname(__DIR__), '.env.testing')->load();
parent::setUpBeforeClass();
}
public function createApplication()
{
return require __DIR__ . '/../bootstrap/app.php';
}
}
.env.testing
APP_ENV=testing
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=db_testing
DB_PORT=3307
DB_DATABASE=db_testing
DB_USERNAME=db_username
DB_PASSWORD=db_password
.env
APP_ENV=local
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3307
DB_DATABASE=db_local
DB_USERNAME=db_username
DB_PASSWORD=db_password
when I debug the testing file like
dd(DB::connection()->getDatabaseName());
it returns db_local instead of db_testing
I don't want to add all my configuration inside phpunit.xml
what is missing? what should I do?