I spent so much time trying to get this working last November and kept running into brick walls. Today, I finally revisited a comment on that same issue by Rouven Hurling that pointed out two excellent notes from Andrea Ercolino.
- How to run WordPress tests in VVV using PHPStorm 8
- How to run WordPress tests in VVV using WP-CLI and PHPStorm 8
These are both great examples of showing your work. Andrea walks through the issue and shows things that didn’t work in addition to things that did. I was able to use the first to quickly solve an issue that I’ve been so close to figuring out, but have missed every time.
And! I haven’t gone through the second article yet, but the hidden gem there is that he has remote debugging with Xdebug working while running tests with PHPUnit. I’ve wanted this so much before.
All that aside (go read those articles!), I stumbled a bit following the instructions and wanted to log some of the settings I had to configure in order for PHPUnit to work properly with PHPStorm 9 and my local configuration.
For this all to work, I had to configure 4 things. The first three are accessed via PHPStorm -> Preferences in OSX. The fourth is accessed via the Run -> Edit Configurations menu in OSX.
A remote PHP interpreter
Choosing “Vagrant” in the Interpreters configuration didn’t work for me. I got an error that VBoxManage wasn’t found in my path when I selected my Vagrant instance and it tried to auto-detect things. I’m not sure if this is a bug or a misconfiguration. I almost wonder if it’s related to my recent upgrade today to Vagrant 1.7.4 and VirtualBox 5.0.
Instead I tried going forward with “SSH Credentials” to see what would happen. I put in the IP of the VVV box, 192.168.50.4, and the vagrant/vagrant username and password combination for SSH. I left the interpreter path alone and when I clicked OK, everything was verified. I was hesitant, because in the first step I had already deviated from the plan.
PHPUnit configuration
This one was easier and didn’t require any altered steps. I added a remote PHPUnit configuration, chose the already configured remote interpreter and was good to close out.
SFTP deployment configuration
Because I was not able to get Vagrant configured properly in the first step, I am dealing with an entirely different path. PHPStorm wants to have a deployment configured over SFTP so that it can be aware of the path structure inside the virtual machine that leads to the tests.
Luckily nothing special needs to happen in the VM to support SFTP, so I was able to add 192.168.50.4 as the server and vagrant/vagrant as the username and password combination.
I originally tried putting the full path to WordPress here as the root directory, but that caused PHPStorm to prepend that on any automatic path building it did. I tried Autodetect as well, but that detected /home/vagrant, which did not work with the WordPress files. Through the power of deduction, I set the actual root / as the root. 😜
I also used the Mappings tab on this screen to match up my local wordpress-develop directory with the one I’m interacting with remotely.
Run/debug configurations
This one ends up being very straight forward now that everything else is configured. All I needed to do is select the phpunit.xml.dist file via its local path on my machine.
And then I was good! I can now run the single site unit tests for WordPress core just by using the Run command via green arrows everywhere in PHPStorm.
The tests took 3.14 minutes to run through the interface versus 2.45 minutes through the command line, but I was given a bunch of information on skipped tests throughout. I’ll likely stick to the command line interface for normal testing, though I’m looking forward to getting Xdebug configured along side this as it will make troubleshooting individual tests for issues a lot easier.
Big thanks again to Andrea Ercolina for the great material that brought me to a working config!
Responses and reactions
Replies
The error "VBoxManage wasn’t found" is a bug of all IntelliJ products, not only PHPStorm, but also PyCharm, RubyMine. There is a workaround found on the stackoverflow, that helped me on OSX:
sudo ln -s /usr/local/bin/VBoxManage /usr/bin/VBoxManage
(http://stackoverflow.com/questions/31395112/error-setting-up-vagrant-with-virtualbox-in-pycharm-under-os-x-10-10)
Nice article!
I got a same problem on PhpStorm 9 + Vagrant 1.7.4 + VirtualBox 5.
I regenerated Interpreters with "SSH Credentials" that worked fine :)
Thank you.
The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.
Learn more about Webmentions.