The function I'm testing requires another plugin, but I want to test it in isolation without having that plugin activated.
function functionName() {
...
if (!is_plugin_active('path/to/plugin.php')) {
return false;
}
return true;
}
How can I simulate that call returning true when I write a unit test?
You can modify the 'active_plugins' option during your tests to include that plugin.
See https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-admin/includes/plugin.php#L434 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.