-
|
Hi there, So, my question is without clearing configuration cache why did one test passes and the other one fail on the same post route? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
CSRF protection is skipped when running tests. That happens in the VerivyCsrfToken middleware. Laravel knows you're running tests if your APP_ENV is set to As a general tip, never run |
Beta Was this translation helpful? Give feedback.
-
|
I resolved this by running the following command: php artisan config:clear |
Beta Was this translation helpful? Give feedback.
CSRF protection is skipped when running tests. That happens in the VerivyCsrfToken middleware. Laravel knows you're running tests if your APP_ENV is set to
testing(which is set automatically in phpunit.xml). When you cache your config file, your APP_ENV is hardcoded to whatever is in your.envfile at the time (probablylocal). Then when you run your tests, Laravel thinks you're not running tests, and will check the CSRF token.As a general tip, never run
artisan optimizeorconfig:cachein development. Only use them in production.