Docker container with PHPUnit: Could not open input file: /var/www/vendor/phpunit/phpunit/phpunit

I'm trying to run my PHPUnit tests from my Docker container within PHPStorm. Currently, I've provisioned both a Docker instance and CLI interpreter in PHPStorm, but PHPStorm is unable to open phpunit in my Docker container, complaining:

"Can not parse PHPUnit version output: Could not open input file: /var/www/vendor/phpunit/phpunit/phpunit"

Why would this be? I can easily execute both `phpunit` and `vendor/bin/phpunit` from within Docker.

2
10 comments

The path mappings on a screenshot are empty. Please adjust them accordingly:

Local path: The path to the local folder that you want to make available for volume bindings.

Virtual machine path: The corresponding directory path in the Docker virtual machine's file system.

 

0
Avatar
Permanently deleted user

Thanks for your reply. Unfortunately I have tried various combinations of path mappings without any success. Here is my docker-compose volume configuration, just to confirm I am providing the correct path mapping:

And here is the same error, with the correct path mapping provided:

0

Hi!
Any news on this?
Got the same problem exactly. Tried phpunit 7/8.

1

Sorry for the probably stupid question but I did notice the "<project root>/src" subdirectory, so, just to confirm, is the "vendor" dir located under "src"?

0

Vasiliy Yur, it is not (for my mapping), IDE mapping was ok for me. I tried changing mapping in various ways (in phpstorm), but only changing mapping in docker-compose.yml worked and fixed the problem.

0
Avatar
Permanently deleted user

I had this exact same problem which was strange because I am using the exact same set up on other projects. All the mappings were correct and docker config was correct. I realised on this project I was using PHPUnit 9 and on others PHPUnit 7. I rolled back to PHPUnit 7 and it all works again.

0
Avatar
Permanently deleted user

Same problem with me, it works on other projects but with both the Symfony PHPUnit bridge and with stanadalone PHPUnit it fails to find both the path to the Phar or the autoloader file. I've tried with path mappings on and off, pointing to the bin/.phpunit/phpunit-8.5.0 directory, trying to point to vendor/bin/simple-phpunit and the autoloader but nothing works.

0

Would it be possible to show a screenshot of your mappings?

0
Avatar
Permanently deleted user

Sorry for the delay, these are my mappings but with some test values in there for "Path to phpunit.phar". I've tried lots of values in here, including both paths from the container like "/var/www/app/bin/phpunit". The current value is because I tried to download PhpUnit directly from the site as a test and see if it would work. I've also tried using composer autoloader (although would prefer to stick to using the Symfony bridge version) but that also fails. I have no trouble running tests from inside the container with:

root@a948175efeb5:/var/www/app# /var/www/app/bin/phpunit
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.
0

No worries at all and thanks for sharing the screenshot.

Actually, there should be a remote path to the PHAR file, not the local one. Please try setting a remote path like "/var/www/app" but specify a downloaded PHAR file with an extension, so finally, it should look like "/var/www/app/phpunit.phar" (or any other location where you keep it).

0

Please sign in to leave a comment.