mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Build/Test Tools: Fix and standardise calls to the tearDown() method in the test suite.
The parent method should be called after any test-specific teardown. See #52625 git-svn-id: https://develop.svn.wordpress.org/trunk@50450 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3542c3b4c0
commit
055deeabff
@ -157,7 +157,6 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
|
||||
* Resets $_POST, removes the wp_die() override, restores error reporting.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
unset( $GLOBALS['post'] );
|
||||
@ -166,6 +165,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
|
||||
remove_action( 'clear_auth_cookie', array( $this, 'logout' ) );
|
||||
error_reporting( $this->_error_level );
|
||||
set_current_screen( 'front' );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,12 +19,12 @@ class Block_Supported_Styles_Test extends WP_UnitTestCase {
|
||||
* Tear down each test method.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
while ( ! empty( $this->registered_block_names ) ) {
|
||||
$block_name = array_pop( $this->registered_block_names );
|
||||
unregister_block_type( $block_name );
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -14,11 +14,11 @@ abstract class WP_Test_REST_Controller_Testcase extends WP_Test_REST_TestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 );
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
abstract public function test_register_routes();
|
||||
|
||||
@ -59,8 +59,8 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* Tear down.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
$_REQUEST = array();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -43,10 +43,10 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
// Cleanup all the global state.
|
||||
unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function test_auth_cookie_valid() {
|
||||
|
||||
@ -44,12 +44,12 @@ class WP_Block_Context_Test extends WP_UnitTestCase {
|
||||
* Tear down each test method.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
while ( ! empty( $this->registered_block_names ) ) {
|
||||
$block_name = array_pop( $this->registered_block_names );
|
||||
unregister_block_type( $block_name );
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -37,9 +37,9 @@ class WP_Block_List_Test extends WP_UnitTestCase {
|
||||
* Tear down each test method.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->registry = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -41,9 +41,9 @@ class WP_Test_Block_Type_Registry extends WP_UnitTestCase {
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->registry = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -36,9 +36,9 @@ class WP_Block_Test extends WP_UnitTestCase {
|
||||
* Tear down each test method.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->registry = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function filter_render_block( $content, $parsed_block ) {
|
||||
|
||||
@ -58,8 +58,6 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
|
||||
* @since 5.0.0
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
|
||||
foreach ( array( 'core/test-static', 'core/test-dynamic', 'tests/notice' ) as $block_name ) {
|
||||
@ -67,6 +65,8 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
|
||||
$registry->unregister( $block_name );
|
||||
}
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -38,8 +38,6 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->test_block_instance_number = 0;
|
||||
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
@ -49,6 +47,8 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
|
||||
if ( $registry->is_registered( 'core/dynamic' ) ) {
|
||||
$registry->unregister( 'core/dynamic' );
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -55,8 +55,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
* Tear down the test case.
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$this->setting = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -93,6 +93,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
|
||||
parent::tearDown();
|
||||
|
||||
// This has to be called after the parent `tearDown()` method.
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test" );
|
||||
}
|
||||
|
||||
|
||||
@ -81,10 +81,11 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
$registry->unregister( 'core/fake' );
|
||||
wp_delete_post( self::$post_id, true );
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -53,7 +53,7 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tears down the test fixture.
|
||||
*/
|
||||
public function teardown() {
|
||||
public function tearDown() {
|
||||
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function' ), 10, 3 );
|
||||
remove_action( 'deprecated_function_trigger_error', '__return_false' );
|
||||
remove_action( 'deprecated_argument_run', array( $this, 'deprecated_argument' ), 10, 3 );
|
||||
|
||||
@ -18,11 +18,11 @@ class Tests_Functions_Referer extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$_SERVER['HTTP_REFERER'] = '';
|
||||
$_SERVER['REQUEST_URI'] = '';
|
||||
$_REQUEST['_wp_http_referer'] = '';
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function _fake_subfolder_install() {
|
||||
|
||||
@ -27,8 +27,8 @@ class Tests_Menu_WpAjaxMenuQuickSeach extends WP_UnitTestCase {
|
||||
*/
|
||||
function tearDown() {
|
||||
global $current_screen;
|
||||
parent::tearDown();
|
||||
$current_screen = $this->current_screen;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -18,8 +18,8 @@ if ( is_multisite() ) :
|
||||
|
||||
function tearDown() {
|
||||
global $wpdb;
|
||||
parent::tearDown();
|
||||
$wpdb->suppress_errors( $this->suppress );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function test_wpmu_log_new_registrations() {
|
||||
|
||||
@ -60,13 +60,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = null;
|
||||
|
||||
remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10 );
|
||||
remove_filter( 'oembed_result', array( $this, 'filter_oembed_result' ), 10 );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -14,8 +14,8 @@ class Tests_Query_CommentCount extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset( $this->q );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||
|
||||
@ -70,8 +70,8 @@ class WP_Test_REST_Application_Passwords_Controller extends WP_Test_REST_Control
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -88,8 +88,6 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
if ( file_exists( $this->test_file ) ) {
|
||||
unlink( $this->test_file );
|
||||
}
|
||||
@ -107,6 +105,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
WP_Image_Editor_Mock::$edit_return = array();
|
||||
WP_Image_Editor_Mock::$size_return = null;
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_register_routes() {
|
||||
|
||||
@ -53,10 +53,10 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
global $wp_rest_additional_fields;
|
||||
$wp_rest_additional_fields = array();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_validate_schema_type_integer() {
|
||||
|
||||
@ -83,11 +83,11 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
if ( file_exists( WP_PLUGIN_DIR . '/test-plugin/test-plugin.php' ) ) {
|
||||
$this->rmdir( WP_PLUGIN_DIR . '/test-plugin' );
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -27,13 +27,12 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = null;
|
||||
|
||||
remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function mock_embed_request( $preempt, $r, $url ) {
|
||||
|
||||
@ -39,8 +39,6 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$settings_to_unregister = array(
|
||||
'mycustomsetting',
|
||||
'mycustomsetting1',
|
||||
@ -55,6 +53,8 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
unregister_setting( 'somegroup', $setting );
|
||||
}
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_register_routes() {
|
||||
|
||||
@ -232,10 +232,6 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertArrayHasKey( 'rest_base', $properties );
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for use in get_public_taxonomies
|
||||
*/
|
||||
|
||||
@ -42,9 +42,9 @@ class Tests_Rewrite_OldDateRedirect extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->old_date_redirect_url = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_old_date_redirect() {
|
||||
|
||||
@ -30,11 +30,10 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$this->old_slug_redirect_url = null;
|
||||
|
||||
remove_filter( 'old_slug_redirect_url', array( $this, 'filter_old_slug_redirect_url' ), 10 );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_old_slug_redirect() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user