PHPUnit testing on a virtualized system

So I'm trying to setup remote unit testing from a virtualized system (how, is not important). I'm using a simple samba connection so my files are accessible locally.

The issue is the fact that PHPStorm uses a very lousy way on figuring out where to store _intellij_phpunit_launcher.php.

An example:

My project consists of a few files:

  • /wwwroot/myproject/public/index.php
  • /wwwroot/myproject/library/library.php
  • /wwwroot/myproject/tests/library/library.php
  • /wwwroot/myproject/phpunit.xml


Obviously, my webroot is set to /public, so other files are not accessible. This is common practice in most projects like symfony2 etc. Locally, i've mounted my /wwwroot as a samba share on /Volumes/www. Server path mappings from /Volumes/www/myproject to /wwwroot/myproject are set and things like remote web & cli debugging work perfectly.

In the "PHPUnit on Server", i choose to use a XML file. I *must* use an alternate configuration file because it can't find phpunit.xml to begin with. Note that everything here must be set with *local* paths (ie: /volumes/www/myproject).

The deployment-server i'm using is of type "in place". However, here I can only set mappings from local paths to *web paths* (not remote paths!). This means my mapping becomes:

/Volumes/www/myproject/public => /

The issue now: the "use alternate configuration file" in the run configuration now is invalid, as i'm using /Volumes/www/myproject/phpunit.xml: it does not know anything about /Volumes/www/myproject/, as our web path mapping is to: /Volumes/www/myproject/public.

So obviously,i changed the path mapping from: /Volumes/www/myproject/ => /
At least now the run configuration does not complain, but the problem is that _intellij_phpunit_launcher.php get copied to this specific directory. Meaning it will get copied /wwwroot/myproject/_intellij_phpunit_launcher.php. Obviously, when phpstorm tries to connect to this file on the webserver it will fail, as this is NOT a web-accessible directory.

It would be REALLY nice if we could have an option to change this and have some kind of "override" where this _intellij_phpunit_launcher.php file is stored. Seems easy enough.

There is no easy way to do this kind of unit-testing (at least, i can't get it running, so i assume there are things i'm missing). But i figured out another way:

I've created an empty dummy.xml file inside the public directory: /wwwroot/myproject/public/dummy.xml
This file I can select as alternative configuration file.

However, i will override this file through the "test runner options" by issuing "-c phpunit.xml".
This does not work out of the box, but we can also change the custom working directory here as well. When using "..", it will actually change to the parent directory of "public", which is the correct directory. My original phpunit.xml will have all it's directories relative from the root of the project so everything works correctly. Using other paths will result in a refusal of PHPStorm running the unit-tests, as you must create additional path mappings.

With this kind of quickfix, at least PHPStorm/_intellij_phpunit_launcher does not complain about files not found, and unit-testing seems to be working correctly.


But obviously, a better fix like being able to set a location where phpstorm stores it's _intellij_phpunit_launcher would be a much better solution.

So, in the end, i have a few questions:
- is this the correct way to deal with remote/virtualized system phpunit testing?
- are there better ways to deal with this?
- are there possibilities to change the location of _intellij_phpunit_launcher another way?
2 comments

Hi there,

BTH -- I did not read whole text (too long) plus I do not have real experience with such setup myself (in my case it was much easier as remote path and local path is the same on both computers; and now I do all my testing locally since target platform is the same).

But have a look at this thread -- maybe you will be able to do the same as Kristopher did:


Related:

0

Hi Andriy,

The post you mentioned seems to have the same problem, but uses a little bit of a different solution: it sets up a new webserver purely for their tests so both the phpunit.xml, tests (and thus _intellij_*.php) are all located at a place where they are accessible through the web interface.

But to be honest, this solution is not really a viable one. Setting up extra hosts should not be something you would need to do, and I would prefer the "hack" i'm suggesting in my code (but this requires a dummy xml in your webroot, which you also don't want).

In fact, i'm strongly leaning to the fact that the only way this will change, is that PHPStorm stops deciding on where it thinks it should place it's _intellij_*.php file, and let the user enter this path. Everything else, ranging from remote code-coverage, remote debugging, remote cli debugging and remote web debugging all work, and i'm currently wrapping up a BIG blogpost on setting up all components correctly in such an environment. If there are no other options available, i'll just send in a bug-report or see if I can patch this myself (phpstorm is opensource?) .

0

Please sign in to leave a comment.