我知道我可以设置环境变量 https://phpunit.de/manual/current/en/appendixes.configuration.html在我的 phpunit.xml 里面
<php>
<env name="MY_VARIABLE" value="foo" />
</php>
所以这很好用
phpunit
// foo
但是,如果该变量已在父 shell 中导出,则该值将被忽略。
export MY_VARIABLE=bar
phpunit
// bar
我需要为其他子进程导出这个值,但我真的不想打开另一个 shell 只是为了运行测试。如何配置 phpunit 以仅使用为测试环境定义的值?
默认情况下定义的环境变量phpunit.xml
被 shell 环境覆盖。此行为与命令行工具中通常使用环境变量的方式一致。设置环境变量时,我们通常希望将其传递给工具并使用它来代替配置的值。
The new force
属性被引入PHP 单元 6.3让我们对所选变量禁用此行为:
<env name="FOO" value="bar" force="true" />
相关github问题:
- https://github.com/sebastianbergmann/phpunit/pull/2723 https://github.com/sebastianbergmann/phpunit/pull/2723
- https://github.com/sebastianbergmann/phpunit/issues/2353 https://github.com/sebastianbergmann/phpunit/issues/2353
- https://github.com/sebastianbergmann/phpunit/issues/1181 https://github.com/sebastianbergmann/phpunit/issues/1181
- https://github.com/sebastianbergmann/phpunit/issues/2353#issuecomment-290702962 https://github.com/sebastianbergmann/phpunit/issues/2353#issuecomment-290702962
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)