Make WordPress Core

Changeset 51869


Ignore:
Timestamp:
09/25/2021 01:27:47 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Remove unnecessary setUp() and tearDown() methods in multisite tests.

These were originally added in [26252] to suppress database errors on setUp() and restore on tearDown() for tests that call wpmu_create_blog(), blog factory, or installation code that attempts to clear transients.

As the multisite test coverage expanded, these methods ended up being unnecessarily copied into other test classes, where database error suppression is not required.

Follow-up to [26252], [29916], [30286], [33184], [34898], [34899], [34901], [37234], [37477], [37894], [49212], [49616], [51859].

See #53363.

Location:
trunk/tests/phpunit/tests
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite.php

    r51568 r51869  
    99         */
    1010        class Tests_Multisite extends WP_UnitTestCase {
    11                 protected $suppress = false;
    12 
    13                 function set_up() {
    14                         global $wpdb;
    15                         parent::set_up();
    16                         $this->suppress = $wpdb->suppress_errors();
    17                 }
    18 
    19                 function tear_down() {
    20                         global $wpdb;
    21                         $wpdb->suppress_errors( $this->suppress );
    22                         parent::tear_down();
    23                 }
    2411
    2512                function test_wpmu_log_new_registrations() {
  • trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php

    r51860 r51869  
    1010         */
    1111        class Tests_Multisite_CleanDirsizeCache extends WP_UnitTestCase {
    12                 protected $suppress = false;
    13 
    14                 function set_up() {
    15                         global $wpdb;
    16                         parent::set_up();
    17                         $this->suppress = $wpdb->suppress_errors();
    18                 }
    19 
    20                 function tear_down() {
    21                         global $wpdb;
    22                         $wpdb->suppress_errors( $this->suppress );
    23                         parent::tear_down();
    24                 }
    2512
    2613                /**
  • trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php

    r51860 r51869  
    99         */
    1010        class Tests_Multisite_GetSpaceAllowed extends WP_UnitTestCase {
    11                 protected $suppress = false;
    12 
    13                 public function set_up() {
    14                         global $wpdb;
    15                         parent::set_up();
    16                         $this->suppress = $wpdb->suppress_errors();
    17                 }
    18 
    19                 public function tear_down() {
    20                         global $wpdb;
    21 
    22                         $wpdb->suppress_errors( $this->suppress );
    23                         parent::tear_down();
    24                 }
    2511
    2612                /**
  • trunk/tests/phpunit/tests/multisite/getSpaceUsed.php

    r51860 r51869  
    88         */
    99        class Tests_Multisite_GetSpaceUsed extends WP_UnitTestCase {
    10                 protected $suppress = false;
    11 
    12                 function set_up() {
    13                         global $wpdb;
    14                         parent::set_up();
    15                         $this->suppress = $wpdb->suppress_errors();
    16                 }
    17 
    18                 function tear_down() {
    19                         global $wpdb;
    20                         $wpdb->suppress_errors( $this->suppress );
    21                         parent::tear_down();
    22                 }
    2310
    2411                function test_get_space_used_switched_site() {
  • trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php

    r51860 r51869  
    1212         */
    1313        class Tests_Multisite_IsUploadSpaceAvailable extends WP_UnitTestCase {
    14                 protected $suppress = false;
    1514
    1615                public function set_up() {
    17                         global $wpdb;
    1816                        parent::set_up();
    19                         $this->suppress = $wpdb->suppress_errors();
    20 
    2117                        update_site_option( 'upload_space_check_disabled', false );
    22                 }
    23 
    24                 public function tear_down() {
    25                         global $wpdb;
    26 
    27                         $wpdb->suppress_errors( $this->suppress );
    28                         parent::tear_down();
    2918                }
    3019
  • trunk/tests/phpunit/tests/multisite/msFilesRewriting.php

    r51860 r51869  
    1313         */
    1414        class Tests_Multisite_msFilesRewriting extends WP_UnitTestCase {
    15                 protected $suppress = false;
    1615
    1716                function set_up() {
    18                         global $wpdb;
    1917                        parent::set_up();
    20                         $this->suppress = $wpdb->suppress_errors();
    21 
    2218                        update_site_option( 'ms_files_rewriting', 1 );
    2319                        ms_upload_constants();
    24                 }
    25 
    26                 function tear_down() {
    27                         global $wpdb;
    28 
    29                         $wpdb->suppress_errors( $this->suppress );
    30 
    31                         parent::tear_down();
    3220                }
    3321
  • trunk/tests/phpunit/tests/multisite/network.php

    r51568 r51869  
    1111        class Tests_Multisite_Network extends WP_UnitTestCase {
    1212                protected $plugin_hook_count = 0;
    13                 protected $suppress          = false;
    1413
    1514                protected static $different_network_id;
    1615                protected static $different_site_ids = array();
    1716
    18                 function set_up() {
    19                         global $wpdb;
    20                         parent::set_up();
    21                         $this->suppress = $wpdb->suppress_errors();
    22                 }
    23 
    2417                function tear_down() {
    25                         global $wpdb, $current_site;
    26                         $wpdb->suppress_errors( $this->suppress );
     18                        global $current_site;
    2719                        $current_site->id = 1;
    2820                        parent::tear_down();
     
    591583                 */
    592584                public function test_wpmu_create_blog_updates_correct_network_site_count() {
     585                        global $wpdb;
     586
    593587                        $original_count = get_blog_count( self::$different_network_id );
    594588
    595                         $site_id = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id );
     589                        $suppress = $wpdb->suppress_errors();
     590                        $site_id  = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id );
     591                        $wpdb->suppress_errors( $suppress );
    596592
    597593                        $result = get_blog_count( self::$different_network_id );
  • trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php

    r51860 r51869  
    1212         */
    1313        class Tests_Multisite_UploadIsUserOverQuota extends WP_UnitTestCase {
    14                 protected $suppress = false;
    1514
    1615                public function set_up() {
    17                         global $wpdb;
    1816                        parent::set_up();
    19                         $this->suppress = $wpdb->suppress_errors();
    20 
    2117                        update_site_option( 'upload_space_check_disabled', false );
    22                 }
    23 
    24                 public function tear_down() {
    25                         global $wpdb;
    26                         $wpdb->suppress_errors( $this->suppress );
    27                         parent::tear_down();
    2818                }
    2919
  • trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php

    r51860 r51869  
    1212        class Tests_Multisite_wpNetworkQuery extends WP_UnitTestCase {
    1313                protected static $network_ids;
    14 
    15                 protected $suppress = false;
    16 
    17                 function set_up() {
    18                         global $wpdb;
    19                         parent::set_up();
    20                         $this->suppress = $wpdb->suppress_errors();
    21                 }
    22 
    23                 function tear_down() {
    24                         global $wpdb;
    25                         $wpdb->suppress_errors( $this->suppress );
    26                         parent::tear_down();
    27                 }
    2814
    2915                public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
  • trunk/tests/phpunit/tests/multisite/wpSiteQuery.php

    r51860 r51869  
    1212                protected static $network_ids;
    1313                protected static $site_ids;
    14 
    15                 protected $suppress = false;
    16 
    17                 function set_up() {
    18                         global $wpdb;
    19                         parent::set_up();
    20                         $this->suppress = $wpdb->suppress_errors();
    21                 }
    22 
    23                 function tear_down() {
    24                         global $wpdb;
    25                         $wpdb->suppress_errors( $this->suppress );
    26                         parent::tear_down();
    27                 }
    2814
    2915                public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
  • trunk/tests/phpunit/tests/option/multisite.php

    r51568 r51869  
    1111         */
    1212        class Tests_Multisite_Option extends WP_UnitTestCase {
    13                 protected $suppress = false;
    14 
    15                 function set_up() {
    16                         global $wpdb;
    17                         parent::set_up();
    18                         $this->suppress = $wpdb->suppress_errors();
    19                 }
    20 
    21                 function tear_down() {
    22                         global $wpdb;
    23                         $wpdb->suppress_errors( $this->suppress );
    24                         parent::tear_down();
    25                 }
    2613
    2714                function test_from_same_site() {
  • trunk/tests/phpunit/tests/user/multisite.php

    r51568 r51869  
    1111         */
    1212        class Tests_Multisite_User extends WP_UnitTestCase {
    13                 protected $suppress = false;
    14 
    15                 function set_up() {
    16                         global $wpdb;
    17                         parent::set_up();
    18                         $this->suppress = $wpdb->suppress_errors();
    19                 }
    20 
    21                 function tear_down() {
    22                         global $wpdb;
    23                         $wpdb->suppress_errors( $this->suppress );
    24                         parent::tear_down();
    25                 }
    2613
    2714                function test_remove_user_from_blog() {
     
    396383                 */
    397384                public function test_add_user_to_blog_invalid_user() {
     385                        global $wpdb;
     386
    398387                        $site_id = self::factory()->blog->create();
    399388
    400                         $result = add_user_to_blog( 73622, $site_id, 'subscriber' );
     389                        $suppress = $wpdb->suppress_errors();
     390                        $result   = add_user_to_blog( 73622, $site_id, 'subscriber' );
     391                        $wpdb->suppress_errors( $suppress );
    401392
    402393                        wp_delete_site( $site_id );
Note: See TracChangeset for help on using the changeset viewer.