When testing a theme or plugin, you can use WP-CLI to scaffold the test suite setup, wp scaffold plugin-test plugin.
So is there a good way to integrate an editor/IDE (VS Code in my case) so that autocompletion (method signatures, etc) works within the tests? Since the test library is installed in /tmp/ the editor is not indexing those files and thus thinks classes and functions are missing.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
In order of preference:
composer require wp-phpunit/wp-phpunit --dev. Depending on the IDE you use you might need to mark the package invendor/as a source directory.- Each IDE allows you to add definitions from external libraries. In PHPStorm it’s
Settings → Languages & Frameworks → PHP → Include Path. - Just copy the files over to some directory in your project and exclude them with
.gitignore(if you use Git for version control).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0