I am using Laravel 5.1 for my app. I am trying to create custom .env file for my testing env. I have called it .env.testing
Here are the internals:
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
Here is my phpunit.xml file:
<?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>
Here is the database.php settings for 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,
],
The problem is that during the tests it still keeps on reading the normal .env file and utilizes the database from there even though I have specifed database 'larabor_testing' in both database.php and .env.testing and have set it up as default in phpunit.xml file
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire