I’m using phpunit to do TDD on a WordPress plugin. One of the requirements is that plugin activation fail if a taxonomy with a predefined name, let’s say “apartments”, is already registered (either by the theme or another plugin).
The problem is, using the standard WordPress phpunit testing suite, the plugin is activated as a “mu-plugin” automatically while the WordPress environment is bootstrapped. This post suggesting manually activating the plugin but we’ve tried that and it doesn’t seem to work (WordPress 5.2.1). In fact, there is zero indication the function in that post does anything. I have a feeling it is because the plugin activation code probably won’t run if a plugin is mu or already activated.
Before going through the code trying to figure out what’s happening, I’m wondering:
Is this even a proper use of phpunit in the context of WordPress plugins?
If it is a proper use, how should I go about setting up such a test (checking if plugin activation fails)?
Help is greatly appreciated.
Read more here:: How can I test plugin activation using phpunit?