如何将自定义php.ini传递给phpunit?
来源使用
get_cfg_var
Run Code Online (Sandbox Code Playgroud)
代替
ini_get
Run Code Online (Sandbox Code Playgroud)
所以不幸的是它不使用ini_set,-d选项等设置的值.
现在传递值的唯一方法是使用额外的php.ini.我如何将其传递给phpunit?
血腥细节:
我尝试用-d传入
phpunit --filter testgetdesc -d SIEF_VALIDATOR_DOC_ROOT="htdocs"
--configuration tests/phpunit.xml tests/configHelperTest.php
public function testgetdesc() {
echo get_cfg_var("SIEF_VALIDATOR_DOC_ROOT")."---test---";
}
Run Code Online (Sandbox Code Playgroud)
它简单地回应"---测试---"
原因是它也使用了ini_set:
https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/Command.php
case 'd': {
$ini = explode('=', $option[1]);
if (isset($ini[0])) {
if (isset($ini[1])) {
ini_set($ini[0], $ini[1]);
} else {
ini_set($ini[0], TRUE);
}
}
}
Run Code Online (Sandbox Code Playgroud)
同样在phpunit.xml中,我有
<php>
<ini name="SIEF_VALIDATOR_DOC_ROOT" value="bar"/>
</php>
Run Code Online (Sandbox Code Playgroud)
哪个不起作用[我不指望它].