Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get Laravel to change APP_ENV to 'testing' #2218

Closed
ultrablue opened this issue Jul 27, 2019 · 5 comments
Closed

I can't get Laravel to change APP_ENV to 'testing' #2218

ultrablue opened this issue Jul 27, 2019 · 5 comments
Labels

Comments

@ultrablue
Copy link

ultrablue commented Jul 27, 2019

Info:

  • Docker version ($ docker --version):
    Docker version 18.09.2, build 6247962

  • Laradock commit ($ git rev-parse HEAD):
    83a24ef

  • System info (Mac, PC, Linux):
    Windows

  • System info disto/version:
    Windows 10

Issue:

Something is overriding Laravel's APP_ENV setting, which is causing unit tests run against the application database instead of a sqlite in-memory database. I've added the following line to the top of routes/web.php:
dd(App::environment());

When I run my tests, that outputs:
local

Here are some relevant configurations:

  • .env: APP_ENV=local
  • phpunit.xml: <env name="APP_ENV" value="testing"/>
  • .env.testing: APP_ENV=testing

I've tried a number of things, including:

  • Clearing caches by running php artisan cache:clear; php artisan config:cache
  • Creating .env.testing with the proper settings.
  • Changed .env to: APP_ENV=testing
  • Clearing the caches many times and before running tests.

I'm forced to conclude that something outside of Laravel is setting APP_ENV. However, I've grepped the laradock directory for 'app_env' and found nothing. So, I'm pretty stumped.

Please let me know if I can provide any other information.

Thanks!


Expected behavior:

At this point, I would like to see the bit that dumps the current APP_ENV output 'testing' when I run a test.


Reproduce:

I don't know?


Relevant Code:

// place a code sample here
@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
@byrontuckett
Copy link

@ultrablue I'm Experiencing this with the multi project setup. Do you ever find a resolution?

@byrontuckett
Copy link

@ultrablue typical.. just after I posted the message.

Busted the cache manually (deleted files under boostrap\cache) and it works as expected with the correct environment.

cd /var/www/app1
 vendor/bin/phpunit --colors=always test/Feature/ExampleTest.php

@ultrablue
Copy link
Author

@byrontuckett Ha, excellent.

I think that I ended up waiting a looooooong time (months), updating Laradock and Laravel, and violá, all cleared up! You're solution is probably better (and could very well be what happened behind the scenes with mine).

Thanks for following up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants