Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tests/phpunit/includes/testcase-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ public static function set_up_before_class() {
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'admin_init', '_maybe_update_themes' );

// Register the core actions.
self::register_core_actions();
}

/**
* Registers the core Ajax actions.
*/
protected static function register_core_actions() {
foreach ( array_merge( self::$_core_actions_get, self::$_core_actions_post ) as $action ) {
if ( function_exists( 'wp_ajax_' . str_replace( '-', '_', $action ) ) ) {
add_action( 'wp_ajax_' . $action, 'wp_ajax_' . str_replace( '-', '_', $action ), 1 );
Expand All @@ -138,6 +144,15 @@ public static function set_up_before_class() {
public function set_up() {
parent::set_up();

/*
* The shared hook snapshot may have been captured before an Ajax test case
* registered these callbacks, then restored after another randomized test.
*/
self::register_core_actions();
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'admin_init', '_maybe_update_themes' );

add_filter( 'wp_doing_ajax', '__return_true' );
add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );

Expand Down
Loading