PHPUnit Plugin Integration Tests: Getting wordpress-tests-lib PHP into IDE (VS Code)
So I've managed to follow the instructions to get the Plugin Integration Tests set up using wp-cli
and the install-wp-tests.sh
script as described in the handbook article:
https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/
After much hassle and debugging of a million things, I even have an example test running, yay! It's possible! Don't give up!
My issue: The custom PHPUnit extensions for WP aren't picked up by my IDE.
- The
/wordpress-tests-lib/
directory is deep in the bowels of my Mac, whereinstall-wp-tests.sh
installed it along with the ghost copy of WP - The code runs when I use the
phpunit
command in the terminal becausebootstrap.php
includes it - But because the testing library is nowhere near my WP directory or the plugin, VS Code (and probably any other IDE) doesn't pick it up, and my test ends up looking like this:
I can't use autocomplete or navigate to source and all those good things.
I can't be the only one with this problem! How do you deal with this?
I'm going to post my janky solution below, but am eager to hear how others make this work for themselves :)
Topic unit-tests ide Wordpress
Category Web