Closed leogermani closed 6 years ago
@leogermani Calling the plugin activation in the context of testing is no different than calling any other method. I don't want to add this in an automated fashion to the scaffolded tests, as it might not be needed (and slow down) or even break other plugins' tests.
You can easily add required setup work to PHP Unit's setUp()
method or similar: https://phpunit.de/manual/5.0/en/fixtures.html
Hi,
Ive been using this tool for a while and I was wondering if there have been a discussion (and if there is some way) to trigger the plugin's activation hook when runing the tests.
The current way plugins are loaded only include the file, but it does not trigger the activation hook registered by the plugin
I started digging into this but then thought that there might already have been some discussion about it and maybe there is a reason why this is not done.
There is one solution described here https://wordpress.stackexchange.com/questions/218100/when-unit-testing-a-plugin-does-the-plugin-need-to-be-in-the-wp-content-plugins, which is calling my callback directly. But I think there is a better way of doing that.
Do you think there is a cleaner way of doing this or maybe even incorporate something to the bootstrap template so it works out of the box? I could help with that.
This is my suggestion, and what I have been using. I edited the
_manually_load_plugin()
function inside the bootstrap.php file and made it add an action to trigger the activation hook.Here is how it would look like in the mustache template.
What do you think?