10

I'm trying to set up PHPUnit in PhpStorm 2017.1 on Windows 10 using a Vagrant box for a Laravel project. I've set up a remote interpreter, and I've been using it for a couple of months now, everything working fine.

I've been asked to do some unit testing so I've set up PhpStorm with PHPUnit, following my coworkers' instructions (PhpStorm on Mac) but when I select autoload.php in my vendor folder I receive the error message

"Can not parse PHPUnit version output: Could not open input file: /vagrant/vendorphpunitphpunitphpunit" (no slashes).

If I run PHPUnit via vagrant ssh in the command line, my tests execute fine, and I can manually select the PHPUnit phar in PhpStorm, but then I'm missing the autoloaded classes, so everything fails.

Screenshot of PhpStorm's PHPUnit config

2
  • 1
    youtrack.jetbrains.com/issue/WI-35806 I guess Commented Apr 5, 2017 at 9:23
  • Seems to be back since WSL integration was introduced this November Commented Nov 26, 2019 at 9:36

4 Answers 4

6

WI-35806 -- seems the same. It was marked as fixed today.

If that's the right ticket then the fix should be available in 2017.1.2 -- you may try EAP build when it will become available if you cannot wait until 2017.1.2 final will be officially released.

Sign up to request clarification or add additional context in comments.

Comments

5

If you get a similar bug when setting up PHPUnit with Docker, then it could also be because of bad volume bindings.

In the following preferences screen, click on the folder icon to Edit Docker Container Settings, then edit the Volume bindings.

enter image description here

2 Comments

Awesome! This hint solved my problem with the path configuration.
setting mine to /var/www/html fixed
1

I know this is an old thread, but for me the issue was I had a messy docker setup and I was running my project from a Makefile which was calling docker-compose up, while PHPStorm runs the newer docker compose up command.

After trying to connect and configure PHPUnit and getting the same error in finding the phpunit file from the autoloader, I decided to check the PHPStorm Services panel. There I saw only my PHP Container as running, while my project actually had 8 other docker containers running (via the Makefile). I dug a bit more and saw that the path mappings of this PHP container (which is different from the PHP container started by the Makefile) was mapped completely wrong (no vendor or source code).

To fix this I simply stopped all running containers externally and started my docker-compose setup from within PHPStorm's Services panel, then opened a terminal and verified that the mappings there are correct.

Afterwards I reconfigured my remote interpreter and autoload path enter image description here

enter image description here

And everything worked fine in testing.

Basically my recommendation would be to check the services panel and see if the container there is the same as the one you started, since this is what PHPStorm will pick up and run your tests in.

Comments

0

In case you configure remote PHP cli interpreter by Docker Compose, if you get a similar bug of parsing PHPUnit version output like this, the reason may comes from using variables in docker-compose.yaml (e.g using $PWD in volume binding).

For instance, if you mount your current directory like this:

...
  volumes:
    - $PWD:/var/www/html

PHPStorm do not know what $PWD really is, therefore it cannot parse PHPUnit output due to volume binding. You should change the variables to a specific value (e.g to ./ in this case):

...
  volumes:
    - ./:/var/www/html

2 Comments

PHPStorm doesn't read your docker-compose for this information and as soon as you run the docker compose file, it expands that parameter to an absolute path.
This is an old question so I guess things have changed but the latest phpstorm version (build #PS-221.5787.33) does not expand shell variables in volume bindings. Hence, changing $PWD to . fixed the issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.