I know this is old but I had the same issue and wanted to leave this to help others.
My setup:
- PHPStorm(8) on my Host.
- CentOS as my Guest (vagrant)
- Tested on Ubuntu and Mac Host
I started first by setting the global settings. This way, all new projects will inherit the default settings. Currently setup projects will need to apply the global settings for this to work.
If you have not setup your default interpreter already, you should do this now. Go to Language & Frameworks->PHP. Make sure the interpreter is setup to use your vagrant interpreter. To do this, click on the ... and select remote, select vagrant and point to your box location. Hit OK and you should see it connect to you box. If all is good, hit OK again to get back to the select box for your default interpreter and click on Apply.
I also recommend going to Tools->Vagrant and setup your default vagrant. This is how my setup is but I don't believe this has any affect on getting PHPUnit to work on Vagrant, just a preference. Just noting this here in case this actually had any affect.
First, let's get PHPStorms autocomplete working.
Download the latest phpunit.phar and save locally on the host. I recommend having a directory strictly for IDE resources and put the phar file in that directory. Go to Language & Frameworks->PHP and add the IDE resources directory to your include path. This will enable autocomplete for your code.
Next, open Default Settings, not project settings (although existing projects will need this done too), and go to Language & Frameworks->PHP->PHPUnit. Under Local, select Path to phpunit.phar and update this to point to your newly downloaded phpunit.phar file.
Next, we need to let PHPUnit be aware of Vagrant.
In Language & Frameworks->PHP->PHPUnit add a new PHPUnit. Select By Remote Interpreter and select your newly added Vagrant Interpreter. Choose your selected method, for me, I tried to use include path but it was giving me errors (didn't care to fix it). I wound up using Use custom autoloader and set my path to /usr/local/bin/phpunit since I installed it manually and this was my path. Basically, all you want to do is let PHPStorm know where PHPUnit is installed if you are experiencing issues with this.
Do not check anything for Test Runner as this is global settings. If you are in a project, then you would need to check Default configuration file and point to your projects phpunit.xml file. This should load your VM and the path should be the location in your VM. If it's not your VM, you selected the wrong interpreter. You will need to do this for any project you want to do unit testing on (unless you created a default phpunit.xml config for all projects and set this in the global settings. Keep in mind, existing project may need to be updated to use the global config.)
Now the environment is setup (assuming you used the above for global and project settings) and the last thing to do is to configure the tests.
On the top-right side of the IDE, next to the debugger icons, is a drop down. Click on it and select Edit Configurations
Add a new PHPUnit test. I named mine, Run Tests and select Defined in configuration file (this is important otherwise it will try to use your local path instead of your Vagrant path.) Apply and Save.
Now your tests should work.
If you have any issues, or are a bit confused, I only set the default (global) settings so all new projects inherit the settings. Basically, your project settings just need to match what's above.
I was having a lot of issues getting this to work and found PHPStorms documentation to be less than helpful. Google brought me here but setting a Deployment is not the proper method to do this.
Hope this helps.
Settings | PHP | PHPUnitplease. Also: youtrack.jetbrains.com/issue/WI-24093#comment=27-778912 - LazyOneDefault configuration file:and use customphpunit.xmlon your PHPUnit settings. 2) CheckedDefined in the configuration fileon your PHPUnit run config (PHPUnitnotPHPunit by HTTP) - Liao San Kai