You're loading your environment file into a new repository instance, but your lumen application has no idea that repository instance exists.
Next, when your bootstrap/app.php
file runs, it'll create the repository instance loaded with your normal .env
file that lumen knows how to use.
The cleanest solution is probably to remove your setUpBeforeClass()
method and just update your bootstrap/app.php
file to support loading different .env files.
One example:
$env = env('APP_ENV');
$file = '.env.'.$env;
// If the specific environment file doesn't exist, null out the $file variable.
if (!file_exists(dirname(__DIR__).'/'.$file)) {
$file = null;
}
// Pass in the .env file to load. If no specific environment file
// should be loaded, the $file parameter should be null.
(new LaravelLumenBootstrapLoadEnvironmentVariables(
dirname(__DIR__),
$file
))->bootstrap();
If you update your bootstrap/app.php
file with this code, then you can have one environment variable specified in your phpunit.xml
file to set the APP_ENV
variable to testing
. If you do that, the above code would load the .env.testing
file.
NB: all theory based on reading code. untested.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…