如何传递自定义php.ini给phpunit?将自定义php.ini传递给phpunit
源使用
get_cfg_var
,而不是
ini_get
所以很遗憾它不使用通过的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---";
}
它只是呼应 “---测试---”
原因是这样使用的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);
}
}
}
另外在phpunit.xml,我有
<php>
<ini name="SIEF_VALIDATOR_DOC_ROOT" value="bar"/>
</php>
不工作[我不指望它。
我不认为phpunit将它传递给php - 请参阅我上面的编辑。 – Fakrudeen
我确认,它不会从代码工作 - https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/Command.php – Fakrudeen
@Fakrudeen:我添加了一个替代品,没有问题来调用phpunit办法。 – hakre