Build/Test tools: Move `wp_doing_ajax` defintion from class setup to test setup.

Moves defintion of ajax request in `WP_Ajax_UnitTestCase` to `setUp()` method to account for hooks being reset as part of `tearDown()`.

Props matthias.thiel for report.
Fixes #41561.



git-svn-id: https://develop.svn.wordpress.org/trunk@41970 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2017-10-23 05:10:25 +00:00
parent 3bcd5075f5
commit a77ccfad80
1 changed files with 1 additions and 2 deletions

View File

@ -59,8 +59,6 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
); );
public static function setUpBeforeClass() { public static function setUpBeforeClass() {
add_filter( 'wp_doing_ajax', '__return_true' );
remove_action( 'admin_init', '_maybe_update_core' ); remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'admin_init', '_maybe_update_plugins' ); remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'admin_init', '_maybe_update_themes' ); remove_action( 'admin_init', '_maybe_update_themes' );
@ -82,6 +80,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
add_filter( 'wp_doing_ajax', '__return_true' );
add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 ); add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
set_current_screen( 'ajax' ); set_current_screen( 'ajax' );