diff --git a/tests/phpunit/tests/multisite.php b/tests/phpunit/tests/multisite.php index deb45b4fe4..22beb7f53c 100644 --- a/tests/phpunit/tests/multisite.php +++ b/tests/phpunit/tests/multisite.php @@ -8,19 +8,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite extends WP_UnitTestCase { - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } function test_wpmu_log_new_registrations() { global $wpdb; diff --git a/tests/phpunit/tests/multisite/cleanDirsizeCache.php b/tests/phpunit/tests/multisite/cleanDirsizeCache.php index 958908f468..b190acd226 100644 --- a/tests/phpunit/tests/multisite/cleanDirsizeCache.php +++ b/tests/phpunit/tests/multisite/cleanDirsizeCache.php @@ -9,19 +9,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_CleanDirsizeCache extends WP_UnitTestCase { - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } /** * Test whether dirsize_cache values are used correctly with a more complex dirsize cache mock. diff --git a/tests/phpunit/tests/multisite/getSpaceAllowed.php b/tests/phpunit/tests/multisite/getSpaceAllowed.php index 97b09ab00c..5e87fc0087 100644 --- a/tests/phpunit/tests/multisite/getSpaceAllowed.php +++ b/tests/phpunit/tests/multisite/getSpaceAllowed.php @@ -8,20 +8,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_GetSpaceAllowed extends WP_UnitTestCase { - protected $suppress = false; - - public function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - public function tear_down() { - global $wpdb; - - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } /** * When no option exists for the site or the network, a fallback of diff --git a/tests/phpunit/tests/multisite/getSpaceUsed.php b/tests/phpunit/tests/multisite/getSpaceUsed.php index 7bad089572..d243fc8efa 100644 --- a/tests/phpunit/tests/multisite/getSpaceUsed.php +++ b/tests/phpunit/tests/multisite/getSpaceUsed.php @@ -7,19 +7,6 @@ if ( is_multisite() ) : * @covers ::get_space_used */ class Tests_Multisite_GetSpaceUsed extends WP_UnitTestCase { - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } function test_get_space_used_switched_site() { $blog_id = self::factory()->blog->create(); diff --git a/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php b/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php index 796bf0f736..bc983d5d46 100644 --- a/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php +++ b/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php @@ -11,23 +11,12 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_IsUploadSpaceAvailable extends WP_UnitTestCase { - protected $suppress = false; public function set_up() { - global $wpdb; parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - update_site_option( 'upload_space_check_disabled', false ); } - public function tear_down() { - global $wpdb; - - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } - /** * A default of 100MB is used when no `blog_upload_space` option * exists at the site or network level. diff --git a/tests/phpunit/tests/multisite/msFilesRewriting.php b/tests/phpunit/tests/multisite/msFilesRewriting.php index 050ae44bb9..4964d7ed8a 100644 --- a/tests/phpunit/tests/multisite/msFilesRewriting.php +++ b/tests/phpunit/tests/multisite/msFilesRewriting.php @@ -12,25 +12,13 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_msFilesRewriting extends WP_UnitTestCase { - protected $suppress = false; function set_up() { - global $wpdb; parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - update_site_option( 'ms_files_rewriting', 1 ); ms_upload_constants(); } - function tear_down() { - global $wpdb; - - $wpdb->suppress_errors( $this->suppress ); - - parent::tear_down(); - } - function test_switch_upload_dir() { $this->assertTrue( is_main_site() ); diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 656db4fbb1..bad6626b56 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -10,20 +10,12 @@ if ( is_multisite() ) : */ class Tests_Multisite_Network extends WP_UnitTestCase { protected $plugin_hook_count = 0; - protected $suppress = false; protected static $different_network_id; protected static $different_site_ids = array(); - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - function tear_down() { - global $wpdb, $current_site; - $wpdb->suppress_errors( $this->suppress ); + global $current_site; $current_site->id = 1; parent::tear_down(); } @@ -590,9 +582,13 @@ if ( is_multisite() ) : * @ticket 38699 */ public function test_wpmu_create_blog_updates_correct_network_site_count() { + global $wpdb; + $original_count = get_blog_count( self::$different_network_id ); - $site_id = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id ); + $suppress = $wpdb->suppress_errors(); + $site_id = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id ); + $wpdb->suppress_errors( $suppress ); $result = get_blog_count( self::$different_network_id ); diff --git a/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php b/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php index 2de3f6b472..5b08569091 100644 --- a/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php +++ b/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php @@ -11,22 +11,12 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_UploadIsUserOverQuota extends WP_UnitTestCase { - protected $suppress = false; public function set_up() { - global $wpdb; parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - update_site_option( 'upload_space_check_disabled', false ); } - public function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } - public function test_upload_is_user_over_quota_allowed_0_used_5() { add_filter( 'get_space_allowed', '__return_zero' ); add_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) ); diff --git a/tests/phpunit/tests/multisite/wpNetworkQuery.php b/tests/phpunit/tests/multisite/wpNetworkQuery.php index 978a2471d9..42fcc21f96 100644 --- a/tests/phpunit/tests/multisite/wpNetworkQuery.php +++ b/tests/phpunit/tests/multisite/wpNetworkQuery.php @@ -12,20 +12,6 @@ if ( is_multisite() ) : class Tests_Multisite_wpNetworkQuery extends WP_UnitTestCase { protected static $network_ids; - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } - public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$network_ids = array( 'wordpress.org/' => array( diff --git a/tests/phpunit/tests/multisite/wpSiteQuery.php b/tests/phpunit/tests/multisite/wpSiteQuery.php index ccfd6c9cb9..f48667f23f 100644 --- a/tests/phpunit/tests/multisite/wpSiteQuery.php +++ b/tests/phpunit/tests/multisite/wpSiteQuery.php @@ -12,20 +12,6 @@ if ( is_multisite() ) : protected static $network_ids; protected static $site_ids; - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } - public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$network_ids = array( 'wordpress.org/' => array( diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index 54388d0144..4a16bb9748 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -10,19 +10,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_Option extends WP_UnitTestCase { - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } function test_from_same_site() { $key = __FUNCTION__ . '_1'; diff --git a/tests/phpunit/tests/user/multisite.php b/tests/phpunit/tests/user/multisite.php index 0b2b1d380a..c73a0bc12b 100644 --- a/tests/phpunit/tests/user/multisite.php +++ b/tests/phpunit/tests/user/multisite.php @@ -10,19 +10,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_Multisite_User extends WP_UnitTestCase { - protected $suppress = false; - - function set_up() { - global $wpdb; - parent::set_up(); - $this->suppress = $wpdb->suppress_errors(); - } - - function tear_down() { - global $wpdb; - $wpdb->suppress_errors( $this->suppress ); - parent::tear_down(); - } function test_remove_user_from_blog() { $user1 = self::factory()->user->create_and_get(); @@ -395,9 +382,13 @@ if ( is_multisite() ) : * @ticket 38356 */ public function test_add_user_to_blog_invalid_user() { + global $wpdb; + $site_id = self::factory()->blog->create(); - $result = add_user_to_blog( 73622, $site_id, 'subscriber' ); + $suppress = $wpdb->suppress_errors(); + $result = add_user_to_blog( 73622, $site_id, 'subscriber' ); + $wpdb->suppress_errors( $suppress ); wp_delete_site( $site_id );