diff --git a/tests/phpunit/includes/testcase-ajax.php b/tests/phpunit/includes/testcase-ajax.php index e351ad2e49..34fd32a392 100644 --- a/tests/phpunit/includes/testcase-ajax.php +++ b/tests/phpunit/includes/testcase-ajax.php @@ -116,6 +116,8 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { ); public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + remove_action( 'admin_init', '_maybe_update_core' ); remove_action( 'admin_init', '_maybe_update_plugins' ); remove_action( 'admin_init', '_maybe_update_themes' ); @@ -126,8 +128,6 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { add_action( 'wp_ajax_' . $action, 'wp_ajax_' . str_replace( '-', '_', $action ), 1 ); } } - - parent::setUpBeforeClass(); } /** diff --git a/tests/phpunit/includes/testcase-block-supports.php b/tests/phpunit/includes/testcase-block-supports.php index fbf6a1408d..f54dba8b9f 100644 --- a/tests/phpunit/includes/testcase-block-supports.php +++ b/tests/phpunit/includes/testcase-block-supports.php @@ -15,13 +15,6 @@ class Block_Supported_Styles_Test extends WP_UnitTestCase { */ private $registered_block_names = array(); - /** - * Sets up each test method. - */ - public function setUp() { - parent::setUp(); - } - /** * Tear down each test method. */ diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index ade4294c6b..09432dedca 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -156,8 +156,8 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { ); function setUp() { - set_current_screen( 'front' ); parent::setUp(); + set_current_screen( 'front' ); } function tearDown() { diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 1b54e5faf8..2004e30ae3 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -15,9 +15,9 @@ class Tests_AdminBar extends WP_UnitTestCase { protected static $user_ids = array(); public static function setUpBeforeClass() { - require_once ABSPATH . WPINC . '/class-wp-admin-bar.php'; - parent::setUpBeforeClass(); + + require_once ABSPATH . WPINC . '/class-wp-admin-bar.php'; } public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { diff --git a/tests/phpunit/tests/comment/getCommentExcerpt.php b/tests/phpunit/tests/comment/getCommentExcerpt.php index c79109cbe4..88c964a3ee 100644 --- a/tests/phpunit/tests/comment/getCommentExcerpt.php +++ b/tests/phpunit/tests/comment/getCommentExcerpt.php @@ -1,17 +1,11 @@ comment->create( diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 0a8a5ab6d7..e0dc8879e7 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -13,10 +13,6 @@ class Tests_Comment_Query extends WP_UnitTestCase { self::$post_id = $factory->post->create(); } - function setUp() { - parent::setUp(); - } - public function test_query() { $c1 = self::factory()->comment->create( array( diff --git a/tests/phpunit/tests/dbdelta.php b/tests/phpunit/tests/dbdelta.php index c54f9cc4dd..ae8d69c5ad 100644 --- a/tests/phpunit/tests/dbdelta.php +++ b/tests/phpunit/tests/dbdelta.php @@ -79,6 +79,8 @@ class Tests_dbDelta extends WP_UnitTestCase { ) ); + // This has to be called after the `CREATE TABLE` above as the `_create_temporary_tables` filter + // causes it to create a temporary table, and a temporary table cannot use a FULLTEXT index. parent::setUp(); } diff --git a/tests/phpunit/tests/feed/wp-simplepie-file.php b/tests/phpunit/tests/feed/wp-simplepie-file.php index 260fa8a7eb..860181d397 100644 --- a/tests/phpunit/tests/feed/wp-simplepie-file.php +++ b/tests/phpunit/tests/feed/wp-simplepie-file.php @@ -17,6 +17,8 @@ */ class Tests_WP_SimplePie_File extends WP_UnitTestCase { public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + require_once ABSPATH . '/wp-includes/class-simplepie.php'; require_once ABSPATH . '/wp-includes/class-wp-simplepie-file.php'; } diff --git a/tests/phpunit/tests/image/editor.php b/tests/phpunit/tests/image/editor.php index ee4b7dc525..47ee30a658 100644 --- a/tests/phpunit/tests/image/editor.php +++ b/tests/phpunit/tests/image/editor.php @@ -19,6 +19,7 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { require_once DIR_TESTDATA . '/../includes/mock-image-editor.php'; + // This needs to come after the mock image editor class is loaded. parent::setUp(); } diff --git a/tests/phpunit/tests/image/editorGd.php b/tests/phpunit/tests/image/editorGd.php index f9d03e6149..2be19f93ef 100644 --- a/tests/phpunit/tests/image/editorGd.php +++ b/tests/phpunit/tests/image/editorGd.php @@ -17,6 +17,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; + // This needs to come after the mock image editor class is loaded. parent::setUp(); } diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index a8bedce079..2d956e44a3 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -18,6 +18,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; require_once DIR_TESTROOT . '/includes/class-wp-test-stream.php'; + // This needs to come after the mock image editor class is loaded. parent::setUp(); } diff --git a/tests/phpunit/tests/image/resizeGd.php b/tests/phpunit/tests/image/resizeGd.php index fc39c9f7f6..55fd8b3bac 100644 --- a/tests/phpunit/tests/image/resizeGd.php +++ b/tests/phpunit/tests/image/resizeGd.php @@ -21,6 +21,7 @@ class Test_Image_Resize_GD extends WP_Tests_Image_Resize_UnitTestCase { require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; + // This needs to come after the mock image editor class is loaded. parent::setUp(); } diff --git a/tests/phpunit/tests/image/resizeImagick.php b/tests/phpunit/tests/image/resizeImagick.php index ae402ee457..8a73572f42 100644 --- a/tests/phpunit/tests/image/resizeImagick.php +++ b/tests/phpunit/tests/image/resizeImagick.php @@ -21,6 +21,7 @@ class Test_Image_Resize_Imagick extends WP_Tests_Image_Resize_UnitTestCase { require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; + // This needs to come after the mock image editor class is loaded. parent::setUp(); } } diff --git a/tests/phpunit/tests/menu/walker-nav-menu.php b/tests/phpunit/tests/menu/walker-nav-menu.php index 9b63d63d54..1352b1d2ff 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu.php +++ b/tests/phpunit/tests/menu/walker-nav-menu.php @@ -23,7 +23,6 @@ class Tests_Menu_Walker_Nav_Menu extends WP_UnitTestCase { $this->walker = new Walker_Nav_Menu(); $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth; - parent::setUp(); } /** diff --git a/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php b/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php index c78161d123..dda5845cc1 100644 --- a/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php +++ b/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php @@ -16,9 +16,10 @@ class Tests_Menu_WpAjaxMenuQuickSeach extends WP_UnitTestCase { * Set up. Workaround set_current_screen( null ) not working due to $hook_suffix not being set. */ function setUp() { + parent::setUp(); + global $current_screen; $this->current_screen = $current_screen; - parent::setUp(); } /** diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index 44cedfc9a6..5fcd7dc1ff 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -4,10 +4,6 @@ * @group post */ class Tests_Post_Formats extends WP_UnitTestCase { - function setUp() { - parent::setUp(); - } - function test_set_get_post_format_for_post() { $post_id = self::factory()->post->create(); diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index d1e88ffbd0..771de856b7 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -5,10 +5,6 @@ */ class Tests_Post_GetPages extends WP_UnitTestCase { - function setUp() { - parent::setUp(); - } - /** * @ticket 23167 */ diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index 234bfdfa4d..a3183c3b25 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -11,20 +11,6 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { protected $pages_global; - public function setUp() { - parent::setUp(); - return; - - foreach ( $this->global_keys as $global_key ) { - if ( isset( $GLOBALS[ $global_key ] ) ) { - $this->global_data[ $global_key ] = $GLOBALS[ $global_key ]; - unset( $GLOBALS[ $global_key ] ); - } else { - $this->global_data[ $global_key ] = null; - } - } - } - public function test_id() { $p = self::factory()->post->create_and_get(); setup_postdata( $p ); diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 5106d0d502..06cf3a30ad 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -133,11 +133,12 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca * @since 5.0.0 */ public function setUp() { + parent::setUp(); + $this->register_test_block(); $this->register_post_context_test_block(); $this->register_non_dynamic_block(); $this->register_dynamic_block_with_boolean_attributes(); - parent::setUp(); } /** diff --git a/tests/phpunit/tests/upload.php b/tests/phpunit/tests/upload.php index 43cd1e338a..4c8b73a8a1 100644 --- a/tests/phpunit/tests/upload.php +++ b/tests/phpunit/tests/upload.php @@ -8,8 +8,8 @@ class Tests_Upload extends WP_UnitTestCase { public $siteurl; function setUp() { - $this->_reset_options(); parent::setUp(); + $this->_reset_options(); } function _reset_options() { diff --git a/tests/phpunit/tests/walker.php b/tests/phpunit/tests/walker.php index c40db21a90..20b91df445 100644 --- a/tests/phpunit/tests/walker.php +++ b/tests/phpunit/tests/walker.php @@ -9,11 +9,9 @@ class Tests_Walker extends WP_UnitTestCase { function setUp() { - - $this->walker = new Walker_Test(); - parent::setUp(); + $this->walker = new Walker_Test(); } function test_single_item() {