Open szepeviktor opened 3 years ago
Does official WordPress unit testing run these hooks on every test?
@leogermani Please advise.
Sorry I missed that.
We still have to see how to adapt it to WorDBless but it shouldn't be difficult.
What the official WP test suite does is to use the special tests_add_filter()
function to schedule the inclusion of the code to be tested.
Here's an example:
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/src/tainacan.php';
add_action('plugins_loaded', function() {
do_action('activate_' . substr(dirname( dirname( __FILE__ ) ), 1) . '/src/tainacan.php');
});
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
Most of it is code generated by wp scaffold plugin-tests my-plugin
.
We need to do something similar. Will look into it as soon as I can.
What the official WP test suite does is to use the special
tests_add_filter()
function to schedule the inclusion of the code to be tested.
I see! So the official one also triggers these filters manually :) https://github.com/timber/starter-theme/pull/113#issuecomment-706737128
No :(
Adds hooks before loading WP.
As we run code in
wp-settings.php
we execute a lot of actions.How to test code hooked to e.g.
after_setup_theme
?