[英]passing custom php.ini to 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>
這不起作用[我不指望它]。
-d
應該工作,因為get_cfg_var
讀取:
$ php -d display.errors2=1 -r "echo get_cfg_var('display.errors2');"
1
要傳遞自定義ini設置(或者使用帶-c <file>
的ini文件到phpunit),請調用它配置:
$ php -d setting=value `which phpunit` <your params>
請參閱: php --help
, http : php --help
Github問題建議使用-c
標志。
php -c custom-php.ini `which phpunit` ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.