Hey,
for some reason, all specified env variables are not available in PHPUnit tests.
Variables in my Homestead.yaml
variables:
- key: APP_ENV
value: local
- key: APP_KEY
value: (random 32 char length string)
- key: DB_DATABASE
value: homestead
- key: DB_USERNAME
value: homestead
- key: DB_PASSWORD
value: secret
In the .env file, located in the laravel root directory, i removed all those variables that i specified in my Homestead.yaml above.
When i access the Laravel app in the browser, everthing is just fine. But when i want to execute the unit tests, no database connection could be established:
PDOException: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)
So it seems, that the variables are not set when the unit tests are executed. I either have to set them in the .env file or overwrite/set the values in the phpunit.xml file.
Any reason for that behaviour?