Build/Test tools: Remove usage of DOING_AJAX
from the test suite, so all tests that expect either an Ajax request or a
non-Ajax request can operate without being skipped. Props Mte90 Fixes #41561 git-svn-id: https://develop.svn.wordpress.org/trunk@41293 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3eff05cb88
commit
e7e9e5b3fb
@ -59,9 +59,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
define( 'DOING_AJAX', true );
|
||||
}
|
||||
add_filter( 'wp_doing_ajax', '__return_true' );
|
||||
|
||||
remove_action( 'admin_init', '_maybe_update_core' );
|
||||
remove_action( 'admin_init', '_maybe_update_plugins' );
|
||||
|
@ -23,8 +23,7 @@ class Tests_Ajax_Response extends WP_UnitTestCase {
|
||||
parent::setUp();
|
||||
|
||||
add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
|
||||
if ( !defined( 'DOING_AJAX' ) )
|
||||
define( 'DOING_AJAX', true );
|
||||
add_filter( 'wp_doing_ajax', '__return_true' );
|
||||
|
||||
// Suppress warnings from "Cannot modify header information - headers already sent by"
|
||||
$this->_error_level = error_reporting();
|
||||
|
@ -1544,9 +1544,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @group ajax
|
||||
*/
|
||||
function test_doing_ajax() {
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
define( 'DOING_AJAX', true );
|
||||
}
|
||||
add_filter( 'wp_doing_ajax', '__return_true' );
|
||||
|
||||
$manager = $this->manager;
|
||||
$this->assertTrue( $manager->doing_ajax() );
|
||||
@ -1560,9 +1558,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* Test ! WP_Customize_Manager::doing_ajax().
|
||||
*/
|
||||
function test_not_doing_ajax() {
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
$this->markTestSkipped( 'Cannot test when DOING_AJAX' );
|
||||
}
|
||||
add_filter( 'wp_doing_ajax', '__return_false' );
|
||||
|
||||
$manager = $this->manager;
|
||||
$this->assertFalse( $manager->doing_ajax() );
|
||||
|
@ -37,10 +37,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Define DOING_AJAX so that wp_die() will be used instead of die().
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
define( 'DOING_AJAX', true );
|
||||
}
|
||||
// Define wp_doing_ajax so that wp_die() will be used instead of die().
|
||||
add_filter( 'wp_doing_ajax', '__return_true' );
|
||||
add_filter( 'wp_die_ajax_handler', array( $this, 'get_wp_die_handler' ), 1, 1 );
|
||||
|
||||
require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
|
||||
|
Loading…
Reference in New Issue
Block a user