stuartherbert / sublime-phpunit

PHPUnit Support for Sublime Text 2
https://github.com/stuartherbert/sublime-phpunit
Other
103 stars 20 forks source link

$_SERVER['PWD'] etc not set #24

Closed llanverygranger closed 11 years ago

llanverygranger commented 11 years ago

This might not be an issue per se, however the $_SERVER array is usually populated with some useful values when php (and indeed phpunit) is run from the command line. It seems that your plug-in does not set any such values?

I use $_SERVER['PWD'] in some of my test code to find the current directory. This is different to dirname() as it doesn't resolve symbolic links.

Anyway my main point is that it is useful to populate $_SERVER with useful values. For some examples try display this array from the command line using PHP. PHPUnit also honours this.

Your script would be far more compatible and have a broader reach if it did populate this system array.

Do you think you might consider it? :-) And if not is there another alternative to getting this information?

stuartherbert commented 11 years ago

$_SERVER is (at least in part) populated from the environment of whatever process runs phpunit. In the case of the plugin, we're getting ST2's environment, which will normally be different from running phpunit by hand from a Terminal window.

I'll update the code to populate $_SERVER['PWD'], but would always urge you to use getcwd() instead in your code. In general, $_SERVER should be treated exactly like $_GET, $_POST et al - an untrusted source of input.