1

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.

4
  • In your config "force="true"" and try Commented May 5 at 9:59
  • That is pretty weird, which version exactly do you have? It could be a new bug from latest version Commented May 5 at 10:46
  • try php artisan config:clear && php artisan config:cache --env=testing && php artisan test. make sure to have a .env.testing with APP_ENV=testing .` Commented May 13 at 13:15
  • Did you find a solution? I have the same problem. Laravel runs in a docker container Commented Aug 19 at 17:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.