I'm trying to run tests on my Laravel application.
here is my phpunit config:
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value="myapp_test"/>
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
and here are my .env variables:
APP_NAME="(my app name)"
APP_LOCALE=en
APP_ENV=local
APP_KEY=(my app key)
APP_DEBUG=true
APP_URL=http://localhost
I'm trying to run it with following command:
php artisan test --env=testing
(although, inside my app docker container in macos)
my first question is:
Why it ignores env=testing? when I'm writing dd(config('app.env')) on my test case setUp, it tells me local
why doesn't it run on 'testing' env?!
my second question is: why does it ignore .env.testing file? it sees it reads from main .env file.
it caused me to accidentally remove my local db twice!
any clue on what's going on?
remind that php artisan cache:clear and deleting all caches did not work for me.
"force="true""and tryphp artisan config:clear && php artisan config:cache --env=testing && php artisan test. make sure to have a.env.testingwithAPP_ENV=testing.`