Passing custom php.ini to phpunit

How to pass custom php.ini to phpunit?

Source uses

get_cfg_var 

instead

 ini_get 

unfortunately, it does not use the values ​​specified ini_set, -d, etc.

The only way to pass the value now is to use additional php.ini. How to pass this to phpunit?

Mountain Information:

I tried going with -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---"; } 

It just echoes "--- test ---"

The reason for this is also 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); } } } 

Also in phpunit.xml I have

 <php> <ini name="SIEF_VALIDATOR_DOC_ROOT" value="bar"/> </php> 

which does not work [and I do not expect this].

+6
source share
2 answers

-d should work because get_cfg_var reads those:

 $ php -d display.errors2=1 -r "echo get_cfg_var('display.errors2');" 1 

To pass ini customization (or, alternatively, an ini file with -c <file> to phpunit), call it:

 $ php -d setting=value `which phpunit` <your params> 

See also: php --help , http://www.phpunit.de/manual/3.6/en/appendixes.configuration.html

+5
source

Problem Github recommends using the -c flag.

 php -c custom-php.ini `which phpunit` ... 
0
source

Source: https://habr.com/ru/post/899039/


All Articles