[8.x] Fix PHPUnit bool server consts result in null #5409
Conversation
After updating to Laravel 8 I suddenly had my test suite failing because telescope would not be disabled properly by `phpunit.xml` anymore. This changes fixed my test suite. I've also created a clean Laravel 8 project and added some tests to demonstrate the issue: hettiger/laravel-env-demo@908d340 Maybe this needs to be addressed in PHPUnit. However I'm adding this workaround here because it's a viable solution IMHO. Maybe should add a note on this in the docs and be done with it…?
@GrahamCampbell @hettiger I do believe it's due to this change in DotEnv package Now server variables expect to be strings only, however it could be bool/int as well IMO. |
This change in Repository/Adapter/ServerConstAdapter.php |
Thanks for clarification @sergiy-petrov; LGTM. Feel free to continue the discussion in a new issue at vlucas/phpdotenv. |
The bug is in PHPUnit. The |
Ping @sebastianbergmann for comment. Maybe there's a use case you know that really needs to not have environment variables be strings. Usually, I'd expect people using environment variables to convert them to an int or a bool when they come to use them, and not mess with how they are stored in the server array. |
I am going to just patch phpdotenv 5.x to convert boolean values from $_ENV and $_SERVER to strings, instead of skipping over them as invalid. This should resolve this issue for people, without needing this hack. |
This reverts commit 1c4af33.
@GrahamCampbell would be great. Thanks! |
phpdotenv |
After updating to Laravel 8 I suddenly had my test suite failing because telescope would not be disabled properly by
phpunit.xml
anymore.This change fixed my test suite.
I've also created a clean Laravel 8 project and added some tests to demonstrate the issue:
hettiger/laravel-env-demo@908d340
Maybe this needs to be addressed in PHPUnit. However I'm adding this workaround here because it's a viable solution IMHO.
Maybe should add a note on this in the docs and be done with it…?