Commit 86f50487 authored by Erick Hitter's avatar Erick Hitter
Browse files

Update tests to deal with table being created during `wp_install()`

PHPUnit doesn't load the plugin until after it's called `wp_install()`, which blocks normal table creation and disables the plugin.
parent 9236b692
......@@ -20,6 +20,14 @@ function _manually_load_plugin() {
define( 'WP_CRON_CONTROL_SECRET', 'testtesttest' );
require dirname( dirname( __FILE__ ) ) . '/cron-control.php';
// Plugin loads after `wp_install()` is called, so we compensate
remove_filter( 'schedule_event', '__return_false' );
add_filter( 'pre_option_cron', array( \Automattic\WP\Cron_Control\Events_Store::instance(), 'get_option' ) );
add_filter( 'pre_update_option_cron', array( \Automattic\WP\Cron_Control\Events_Store::instance(), 'update_option' ), 10, 2 );
add_filter( 'schedule_event', array( \Automattic\WP\Cron_Control\Events_Store::instance(), 'block_creation_if_job_exists' ) );
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment