我有一些问题,让Laravel加载我的测试用例正确的.env文件。 我使用PHPUnit的与phpunit.xml以下VAR集:Laravel PHPUnit加载.env.testing文件
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/Http/routes.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
在我.env.testing文件我有:
APP_ENV=testing
DB_CONNECTION=sqlite
,我有他的联系下,配置设置/ database.php:
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
]
它只是不加载.env.testing文件。如果我这样做,我TestCase.php:
dd(env('APP_ENV'));
我还是从我.ENV文件
我也尝试使用得到“发展”:
$app->loadEnvironmentFrom('.env.testing');
像线程建议here
有没有人有什么想法可能是错的?
您使用的是什么版本的Laravel? –
@RossWilson我正在使用版本5.2 – Bisgaard
你能分享你的完整phpunit.xml文件吗? – Sandeesh