PHPUnit on Vagrant Box Question
Hi all,
I'm trying to set up a CentOS 6.4 Vagrant box on my Windows 8 PC to run PHPUnit tests through PHPStorm 7
I'm currently using a hacky custom loader (slight modification on https://gist.github.com/calbrecht/6760441) to run the PHPUnit tests (which are in a shared folder) on the Vagrant box. This works reasonably well for actually running the tests but things get more tricky when I try to debug the tests. I think the issue is that PHPStorm assumes that I'm trying to use Xdebug locally rather than remotely. I've managed to get around this by launching a "PHP Remote Debug" configuration with IDE key "PHPStorm" and then tell Xdebug to connect to that when running the PHPUnit tests with the custom loader
I imagine the solution to this fiddly workaround is to use PHPStorm's "PHPUnit on Server" feature. However, when I try to run the unit tests using this option I get the following output:
Testing started at 15:38 ...
Executing tests
Could not read "E:/tests/phpunit.xml".
The httpd logs are as follows:
[Tue Dec 17 15:38:51 2013] [error] [client 10.0.2.2] PHP Warning: chdir(): No such file or directory (errno 2) in /vagrant/tests/_intellij_phpunit_launcher.php on line 411
[Tue Dec 17 15:38:51 2013] [error] [client 10.0.2.2] PHP Stack trace:
[Tue Dec 17 15:38:51 2013] [error] [client 10.0.2.2] PHP 1. {main}() /vagrant/tests/_intellij_phpunit_launcher.php:0
[Tue Dec 17 15:38:51 2013] [error] [client 10.0.2.2] PHP 2. IDE_PHPUnit_Remote_Command::main() /vagrant/tests/_intellij_phpunit_launcher.php:475
[Tue Dec 17 15:38:51 2013] [error] [client 10.0.2.2] PHP 3. chdir() /vagrant/tests/_intellij_phpunit_launcher.php:411
As far as I know, I have set up all the configurations and mappings correctly. The server connection type is specified as "In place" due to the shared folder. My thoughts are that PHPStorm is passing a windows style directory structure to CentOS which doesn't know what to do with it. Does anyone have any ideas for what to try, or how to possibly debug the autogenerated _intellij_phpunit_launcher?
Thanks
请先登录再写评论。
Hi there,
It's definitely should not be this way (assuming you are using "PHPUnit on Server"). Right now PhpStorm does it correctly -- since deployment is "In place" .. it sends local Windows path (as there is nothing to "transform" during deployment -- path remains the same). You definitely need to setup (S)FTP and use it instead.
BTW (in case you don't know) -- "PHPUnit on Server" executes tests via web interface (while "PHPUnit" one does it in CLI environment)
1) Configure xdebug to launch debug session on EACH request: xdebug.remote_autostart = 1
2) Use Zero-Configuration debug approach (the one that involves usage of phone handle icon) -- http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
Hi,
Thanks for your help
I don't understand why I should need to use (S)FTP when my files are already on the server via the shared folder - would the "Local or Mounted Folder" setting work with "PHPUnit on Server"?
I have tried this but it made PHP hang when "Listen for debugger connections" (the telephone icon) was not activated as xdebug was waiting for a response. The hacky PHPUnit loader gets around this by calling export XDEBUG_CONFIG="idekey=PHPStorm" just before phpunit is run on the vagrant box. It still requires the extra PHP Remote Debug configuration to be running though as debugging a "PHPUnit" configuration seems to generate a random IDEkey
Whatever -- as long as local path can be CORRECTLY "transformed" into correct remote path.