问题
the manual says phpunit -d key=val
allows any setting that is valid on the ini file. the exact same description of php -d
but for me it is doing absolutely nothing.
test using php alone:
$ cat test.php
<?php
var_dump( get_cfg_var('hello') );
?>
$ php -d hello=world test.php
string(5) "world"
all good! now what i get on phpunit:
$ cat test.php
<?php
class MyTest extends PHPUnit_Framework_TestCase {
public function testA(){
var_dump( get_cfg_var('hello') );
}
}
?>
$ phpunit -d hello=world test.php
PHPUnit 3.7.35 by Sebastian Bergmann.
.bool(false)
how can i pass cfg_vars into phpunit via the command line?
回答1:
The -d
option set the ini variable using the ini_set
function, has you can see in the source code here.
So if you can change your code, you can take a value passed from the command line with the -c flag with the ini_get
, as example try as follow:
public function testA(){
var_dump( ini_get('hello') );
}
from the docs about get_cfg_var
;
get_cfg_var() will return strictly the server php.ini
Hope this help
来源:https://stackoverflow.com/questions/32465007/phpunit-d-flag-limitations