Make WordPress Core

Changeset 50450


Ignore:
Timestamp:
02/27/2021 05:08:26 PM (6 years ago)
Author:
johnbillion
Message:

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

Location:
trunk/tests/phpunit
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-ajax.php

    r50449 r50450  
    158158         */
    159159        public function tearDown() {
    160                 parent::tearDown();
    161160                $_POST = array();
    162161                $_GET  = array();
    … …  
    167166                error_reporting( $this->_error_level );
    168167                set_current_screen( 'front' );
     168                parent::tearDown();
    169169        }
    170170
  • trunk/tests/phpunit/includes/testcase-block-supports.php

    r50449 r50450  
    2020         */
    2121        public function tearDown() {
    22                 parent::tearDown();
    23 
    2422                while ( ! empty( $this->registered_block_names ) ) {
    2523                        $block_name = array_pop( $this->registered_block_names );
    2624                        unregister_block_type( $block_name );
    2725                }
     26
     27                parent::tearDown();
    2828        }
    2929
  • trunk/tests/phpunit/includes/testcase-rest-controller.php

    r46586 r50450  
    1515
    1616        public function tearDown() {
    17                 parent::tearDown();
    1817                remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 );
    1918                /** @var WP_REST_Server $wp_rest_server */
    2019                global $wp_rest_server;
    2120                $wp_rest_server = null;
     21                parent::tearDown();
    2222        }
    2323
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r49603 r50450  
    6060         */
    6161        public function tearDown() {
     62                $_REQUEST = array();
    6263                parent::tearDown();
    63                 $_REQUEST = array();
    6464        }
    6565
  • trunk/tests/phpunit/tests/auth.php

    r50284 r50450  
    4444
    4545        public function tearDown() {
    46                 parent::tearDown();
    47 
    4846                // Cleanup all the global state.
    4947                unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
     48
     49                parent::tearDown();
    5050        }
    5151
  • trunk/tests/phpunit/tests/blocks/block-context.php

    r48937 r50450  
    4545         */
    4646        public function tearDown() {
    47                 parent::tearDown();
    48 
    4947                while ( ! empty( $this->registered_block_names ) ) {
    5048                        $block_name = array_pop( $this->registered_block_names );
    5149                        unregister_block_type( $block_name );
    5250                }
     51
     52                parent::tearDown();
    5353        }
    5454
  • trunk/tests/phpunit/tests/blocks/block-list.php

    r48937 r50450  
    3838         */
    3939        public function tearDown() {
     40                $this->registry = null;
     41
    4042                parent::tearDown();
    41 
    42                 $this->registry = null;
    4343        }
    4444
  • trunk/tests/phpunit/tests/blocks/block-type-registry.php

    r48939 r50450  
    4242         */
    4343        public function tearDown() {
     44                $this->registry = null;
     45
    4446                parent::tearDown();
    45 
    46                 $this->registry = null;
    4747        }
    4848
  • trunk/tests/phpunit/tests/blocks/block.php

    r50123 r50450  
    3737         */
    3838        public function tearDown() {
     39                $this->registry = null;
     40
    3941                parent::tearDown();
    40 
    41                 $this->registry = null;
    4242        }
    4343
  • trunk/tests/phpunit/tests/blocks/register.php

    r49982 r50450  
    5959         */
    6060        function tearDown() {
    61                 parent::tearDown();
    62 
    6361                $registry = WP_Block_Type_Registry::get_instance();
    6462
    … …  
    6866                        }
    6967                }
     68
     69                parent::tearDown();
    7070        }
    7171
  • trunk/tests/phpunit/tests/blocks/render.php

    r48937 r50450  
    3939         */
    4040        public function tearDown() {
    41                 parent::tearDown();
    42 
    4341                $this->test_block_instance_number = 0;
    4442
    … …  
    5048                        $registry->unregister( 'core/dynamic' );
    5149                }
     50
     51                parent::tearDown();
    5252        }
    5353
  • trunk/tests/phpunit/tests/customize/custom-css-setting.php

    r48939 r50450  
    5656         */
    5757        function tearDown() {
     58                $this->setting = null;
    5859                parent::tearDown();
    59                 $this->setting = null;
    6060        }
    6161
  • trunk/tests/phpunit/tests/dbdelta.php

    r50449 r50450  
    9494                parent::tearDown();
    9595
     96                // This has to be called after the parent `tearDown()` method.
    9697                $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test" );
    9798        }
  • trunk/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php

    r48937 r50450  
    8282         */
    8383        function tearDown() {
    84                 parent::tearDown();
    8584                $registry = WP_Block_Type_Registry::get_instance();
    8685                $registry->unregister( 'core/fake' );
    8786                wp_delete_post( self::$post_id, true );
     87
     88                parent::tearDown();
    8889        }
    8990
  • trunk/tests/phpunit/tests/functions/deprecated.php

    r49024 r50450  
    5454         * Tears down the test fixture.
    5555         */
    56         public function teardown() {
     56        public function tearDown() {
    5757                remove_action( 'deprecated_function_run', array( $this, 'deprecated_function' ), 10, 3 );
    5858                remove_action( 'deprecated_function_trigger_error', '__return_false' );
  • trunk/tests/phpunit/tests/functions/referer.php

    r49006 r50450  
    1919
    2020        public function tearDown() {
    21                 parent::tearDown();
    22 
    2321                $_SERVER['HTTP_REFERER']      = '';
    2422                $_SERVER['REQUEST_URI']       = '';
    2523                $_REQUEST['_wp_http_referer'] = '';
     24
     25                parent::tearDown();
    2626        }
    2727
  • trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

    r50449 r50450  
    2828        function tearDown() {
    2929                global $current_screen;
     30                $current_screen = $this->current_screen;
    3031                parent::tearDown();
    31                 $current_screen = $this->current_screen;
    3232        }
    3333
  • trunk/tests/phpunit/tests/multisite.php

    r48937 r50450  
    1919                function tearDown() {
    2020                        global $wpdb;
     21                        $wpdb->suppress_errors( $this->suppress );
    2122                        parent::tearDown();
    22                         $wpdb->suppress_errors( $this->suppress );
    2323                }
    2424
  • trunk/tests/phpunit/tests/oembed/controller.php

    r50441 r50450  
    6161
    6262        public function tearDown() {
    63                 parent::tearDown();
    6463                /** @var WP_REST_Server $wp_rest_server */
    6564                global $wp_rest_server;
    … …  
    6867                remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10 );
    6968                remove_filter( 'oembed_result', array( $this, 'filter_oembed_result' ), 10 );
     69                parent::tearDown();
    7070        }
    7171
  • trunk/tests/phpunit/tests/query/commentCount.php

    r49603 r50450  
    1515
    1616        public function tearDown() {
     17                unset( $this->q );
    1718                parent::tearDown();
    18                 unset( $this->q );
    1919        }
    2020
  • trunk/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php

    r50284 r50450  
    7171
    7272        public function tearDown() {
     73                unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
    7374                parent::tearDown();
    74                 unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
    7575        }
    7676
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r50150 r50450  
    8989
    9090        public function tearDown() {
    91                 parent::tearDown();
    92 
    9391                if ( file_exists( $this->test_file ) ) {
    9492                        unlink( $this->test_file );
    … …  
    108106                        WP_Image_Editor_Mock::$size_return = null;
    109107                }
     108
     109                parent::tearDown();
    110110        }
    111111
  • trunk/tests/phpunit/tests/rest-api/rest-controller.php

    r50007 r50450  
    5454
    5555        public function tearDown() {
    56                 parent::tearDown();
    57 
    5856                global $wp_rest_additional_fields;
    5957                $wp_rest_additional_fields = array();
     58
     59                parent::tearDown();
    6060        }
    6161
  • trunk/tests/phpunit/tests/rest-api/rest-plugins-controller.php

    r49951 r50450  
    8484
    8585        public function tearDown() {
    86                 parent::tearDown();
    87 
    8886                if ( file_exists( WP_PLUGIN_DIR . '/test-plugin/test-plugin.php' ) ) {
    8987                        $this->rmdir( WP_PLUGIN_DIR . '/test-plugin' );
    9088                }
     89
     90                parent::tearDown();
    9191        }
    9292
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r50072 r50450  
    2828
    2929        public function tearDown() {
    30                 parent::tearDown();
    31 
    3230                /** @var WP_REST_Server $wp_rest_server */
    3331                global $wp_rest_server;
    … …  
    3533
    3634                remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 );
     35                parent::tearDown();
    3736        }
    3837
  • trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r49603 r50450  
    4040
    4141        public function tearDown() {
    42                 parent::tearDown();
    43 
    4442                $settings_to_unregister = array(
    4543                        'mycustomsetting',
    … …  
    5654                        }
    5755                }
     56
     57                parent::tearDown();
    5858        }
    5959
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r49603 r50450  
    233233        }
    234234
    235         public function tearDown() {
    236                 parent::tearDown();
    237         }
    238 
    239235        /**
    240236         * Utility function for use in get_public_taxonomies
  • trunk/tests/phpunit/tests/rewrite/oldDateRedirect.php

    r49603 r50450  
    4343
    4444        public function tearDown() {
     45                $this->old_date_redirect_url = null;
     46
    4547                parent::tearDown();
    46 
    47                 $this->old_date_redirect_url = null;
    4848        }
    4949
  • trunk/tests/phpunit/tests/rewrite/oldSlugRedirect.php

    r48937 r50450  
    3131
    3232        public function tearDown() {
    33                 parent::tearDown();
    34 
    3533                $this->old_slug_redirect_url = null;
    3634
    3735                remove_filter( 'old_slug_redirect_url', array( $this, 'filter_old_slug_redirect_url' ), 10 );
     36                parent::tearDown();
    3837        }
    3938
Note: See TracChangeset for help on using the changeset viewer.