Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
#[RequiresEnvironmentVariable]
#6074#[RequiresEnvironmentVariable]
#6074Changes from all commits
7263676
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variable can be strictly only string.
What is the meaning of
null
,bool
,int
?Can I test environment variable presence/absence /wo specific value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on https://github.com/sebastianbergmann/phpunit/pull/6074/files#diff-8f0e8d461aea381bf08d49440fbc5da892d38eb782518cd44bfe1dddce7638f4R119 it seems
bool
andint
should be removed and as never possible - see https://www.php.net/manual/en/function.getenv.php return type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can only test environment variable presence or with a specific value
this was more or less my concern here. I'm also wondering if we should only check the env var in
$_ENV
, or usegetenv()
or check at least one of themThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any thoughts @sebastianbergmann? I can provide a patch to my PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test the behaviour with E2E test and some tests in separate process. The separate process must see the same environment variables in both linux and Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think in the case of "no value", I check if the env var exist, or should I check it is ok-ish? empty string and
'0'
would not passThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#6074
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion:
If an environment variable is tested for a presence (/wo value defined in the Attribute), I would expect
'0'
to be consideted as set.For binary
'1'
/'0'
detection I would expect user to write#[RequiresEnvironmentVariable('foo', '1')]
explicitly.''
should be considered as unset as in many operating systemsFOO=
unsets the variable. Also, in CI parametrization/matrix empty value might be set, but with "no variable" meaning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, good point