Laravel v5.5.14
PHPUnit v6.4.1
I have a Laravel application with a number of feature tests. My base TestCase
uses the RefreshDatabase
trait for triggering a DB refresh before each test, and the env variables in my phpunit.xml
looks like so;
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
The intention being to leave the development mysql
DB connection alone and run the tests using sqlite in memory. Despite these settings (and clearing cached config etc) the DB refresh always refreshes the mysql
connection DB.
I've looked into the functionality within RefreshDatabase
and debugged the refreshDatabase
method, which contians;
$this->usingInMemoryDatabase()
? $this->refreshInMemoryDatabase()
: $this->refreshTestDatabase();
And usingInMemoryDatabase
always returns false. Looking at the content of that method, when retrieving the DB_CONNECTION
from config
it always returns mysql
, even though it should be being overridden by the env variable above.
What is going on here?
Aucun commentaire:
Enregistrer un commentaire