This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
3 Replies Last post: Dec 18, 2013 3:11 PM by Andriy Bazanov  
David Broder-Rodgers Newbie 2 posts since
Dec 17, 2013
Currently Being Moderated

Dec 17, 2013 8:54 PM

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

Andriy Bazanov Master 4,165 posts since
May 28, 2010
Currently Being Moderated
Dec 17, 2013 9:08 PM in response to: David Broder-Rodgers
Re: PHPUnit on Vagrant Box Question

Hi there,

 

The server connection type is specified as "In place" due to the shared folder.

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)

 

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

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

Andriy Bazanov Master 4,165 posts since
May 28, 2010
Currently Being Moderated
Dec 18, 2013 3:11 PM in response to: David Broder-Rodgers
Re: PHPUnit on Vagrant Box Question
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"?

Whatever -- as long as local path can be CORRECTLY "transformed" into correct remote path.

More Like This

  • Retrieving data ...