1
我爲我的應用程序使用Laravel 5.1。 我想爲我的測試環境創建自定義的.env文件。我把它稱爲.env.testing爲什麼Laravel不斷使用.env進行測試?
這裏是內部:
APP_ENV=testing
APP_DEBUG=true
APP_KEY=sQy8pV7uVnVtQrL3wBIPESJXhVCYGVyE
DB_HOST=localhost
DB_DATABASE=larabor_testing
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync
MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
這裏是我的phpunit.xml文件:
<?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"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_DEFAULT" value="mysql_testing"/>
</php>
</phpunit>
這裏是爲database.php mysql_testing設置:
'mysql_testing' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'larabor_testing',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'zabor_t_',
'strict' => false,
],
的問題是,在測試過程中它仍保持在讀正常.ENV文件,並在這兩個database.php中和.env.testing利用數據庫中,即使我已經specifed數據庫「larabor_testing」有並已在phpunit.xml文件