first of all, my plugin works on wordpress (it's currently running on production) and creates the DB tables as expected.
I recently just started implementing tests and I have the following problem now:
I have set up the testing environment according to the official wordpress documentation.
I can execute phpunit and run the example test provided by wordpress without any errors.
I would now like to test the activation of my plugin and also whether the tables that are normally created during activation are available. (I have a connection the testing db.)
public function testPluginActivation(): void
{
do_action('activate_' . static::PLUGIN_BASENAME);
}
My problems:
- I am not sure if the code above actually simulates a correct activation.
- I don't know how to prove if the tables are being created. (If I take a look at the testing db after running the tests, the tables are not there, only the default ones created by WP at the beginning, but I am not sure if WP kinda does a rollback after all tests.)
question from:
https://stackoverflow.com/questions/65842294/wordpress-testing-check-if-plugin-activation-has-successfully-created-custom-ta 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…