Make WordPress Core

Changeset 50463


Ignore:
Timestamp:
03/01/2021 06:42:49 PM (5 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Remove redundant teardown functionality from individual tests which is already covered in the base teardown method.

See #52625

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php

    r49603 r50463  
    1919                unset( $GLOBALS['comment'] );
    2020                parent::tearDown();
    21 
    22                 add_filter( 'comment_email', 'antispambot' );
    2321        }
    2422
  • trunk/tests/phpunit/tests/db.php

    r49193 r50463  
    3434                $this->_queries = array();
    3535                add_filter( 'query', array( $this, 'query_filter' ) );
    36         }
    37 
    38         /**
    39          * Tear down the test fixture
    40          */
    41         public function tearDown() {
    42                 remove_filter( 'query', array( $this, 'query_filter' ) );
    43                 parent::tearDown();
    4436        }
    4537
  • trunk/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php

    r50450 r50463  
    8484                $registry = WP_Block_Type_Registry::get_instance();
    8585                $registry->unregister( 'core/fake' );
    86                 wp_delete_post( self::$post_id, true );
    8786
    8887                parent::tearDown();
  • trunk/tests/phpunit/tests/formatting/redirect.php

    r50337 r50463  
    1010                parent::setUp();
    1111                add_filter( 'home_url', array( $this, 'home_url' ) );
    12         }
    13 
    14         function tearDown() {
    15                 remove_filter( 'home_url', array( $this, 'home_url' ) );
    16                 parent::tearDown();
    1712        }
    1813
  • trunk/tests/phpunit/tests/functions/doEnclose.php

    r49006 r50463  
    2727                parent::setUp();
    2828                add_filter( 'pre_http_request', array( $this, 'fake_http_request' ), 10, 3 );
    29         }
    30 
    31         /**
    32          * Cleanup after each test method.
    33          *
    34          * @since 5.3.0
    35          */
    36         public function tearDown() {
    37                 parent::tearDown();
    38                 remove_filter( 'pre_http_request', array( $this, 'fake_http_request' ) );
    3929        }
    4030
  • trunk/tests/phpunit/tests/general/wpGetDocumentTitle.php

    r50339 r50463  
    5454        }
    5555
    56         function tearDown() {
    57                 wp_reset_postdata();
    58                 parent::tearDown();
    59         }
    60 
    6156        function _add_title_tag_support() {
    6257                add_theme_support( 'title-tag' );
  • trunk/tests/phpunit/tests/general/wpResourceHints.php

    r50392 r50463  
    2828                $GLOBALS['wp_scripts'] = $this->old_wp_scripts;
    2929                $GLOBALS['wp_styles']  = $this->old_wp_styles;
    30                 add_action( 'wp_default_scripts', 'wp_default_scripts' );
    31                 add_action( 'wp_default_styles', 'wp_default_styles' );
    3230                parent::tearDown();
    3331        }
  • trunk/tests/phpunit/tests/http/base.php

    r50344 r50463  
    4040        }
    4141
    42         function tearDown() {
    43                 foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) {
    44                         remove_filter( "use_{$t}_transport", '__return_false' );
    45                 }
    46                 parent::tearDown();
    47         }
    48 
    4942        function filter_http_request_args( array $args ) {
    5043                $this->http_request_args = $args;
  • trunk/tests/phpunit/tests/http/wpGetHttpHeaders.php

    r50345 r50463  
    1515                // Hook a fake HTTP request response.
    1616                add_filter( 'pre_http_request', array( $this, 'fake_http_request' ), 10, 3 );
    17         }
    18 
    19         /**
    20          * Clean up environment
    21          */
    22         public function tearDown() {
    23                 parent::tearDown();
    24 
    25                 // Clear the hook for the fake HTTP request response.
    26                 remove_filter( 'pre_http_request', array( $this, 'fake_http_request' ) );
    2717        }
    2818
  • trunk/tests/phpunit/tests/image/base.php

    r49009 r50463  
    1717
    1818                add_filter( 'wp_image_editors', array( $this, 'setEngine' ), 10, 2 );
    19         }
    20 
    21         /**
    22          * Undo the image editor override
    23          */
    24         public function tearDown() {
    25                 remove_filter( 'wp_image_editors', array( $this, 'setEngine' ), 10, 2 );
    26                 parent::tearDown();
    2719        }
    2820
  • trunk/tests/phpunit/tests/image/resize.php

    r49033 r50463  
    1515
    1616                add_filter( 'wp_image_editors', array( $this, 'wp_image_editors' ) );
    17         }
    18 
    19         public function tearDown() {
    20                 remove_filter( 'wp_image_editors', array( $this, 'wp_image_editors' ) );
    21 
    22                 parent::tearDown();
    2317        }
    2418
  • trunk/tests/phpunit/tests/import/import.php

    r48937 r50463  
    3232                        $wpdb->query( "DELETE FROM {$wpdb->$table}" );
    3333                }
    34         }
    35 
    36         function tearDown() {
    37                 remove_filter( 'import_allow_create_users', '__return_true' );
    38 
    39                 parent::tearDown();
    4034        }
    4135
  • trunk/tests/phpunit/tests/l10n/getUserLocale.php

    r50456 r50463  
    2222
    2323        public function tearDown() {
    24                 delete_user_meta( $this->user_id, 'locale' );
    2524                set_current_screen( 'front' );
    2625
  • trunk/tests/phpunit/tests/l10n/loadTextdomain.php

    r50456 r50463  
    2727        }
    2828
    29         public function tearDown() {
    30                 remove_filter( 'plugin_locale', array( $this, 'store_locale' ) );
    31                 remove_filter( 'theme_locale', array( $this, 'store_locale' ) );
    32 
    33                 parent::tearDown();
    34         }
    35 
    3629        public function store_locale( $locale ) {
    3730                $this->locale = $locale;
  • trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

    r50456 r50463  
    4141        public function tearDown() {
    4242                $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
    43                 remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
    44                 remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
    45                 remove_filter( 'template_root', array( $this, 'filter_theme_root' ) );
    4643                wp_clean_themes_cache();
    4744                unset( $GLOBALS['wp_themes'] );
  • trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php

    r48937 r50463  
    1111                protected $suppress = false;
    1212
    13                 protected static $original_site_blog_upload_space;
    14                 protected static $original_blog_upload_space;
    15 
    16                 public static function setUpBeforeClass() {
    17                         parent::setUpBeforeClass();
    18 
    19                         self::$original_site_blog_upload_space = get_site_option( 'blog_upload_space' );
    20                         self::$original_blog_upload_space      = get_option( 'blog_upload_space' );
    21                 }
    22 
    2313                public function setUp() {
    2414                        global $wpdb;
     
    2919                public function tearDown() {
    3020                        global $wpdb;
    31 
    32                         /**
    33                          * Reset the two `blog_upload_space` options to their original values so
    34                          * they can be relied on in other test classes.
    35                          */
    36                         update_site_option( 'blog_upload_space', self::$original_site_blog_upload_space );
    37                         update_option( 'blog_upload_space', self::$original_blog_upload_space );
    3821
    3922                        $wpdb->suppress_errors( $this->suppress );
  • trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php

    r46586 r50463  
    1414                protected $suppress = false;
    1515
    16                 protected static $original_site_blog_upload_space;
    17                 protected static $original_blog_upload_space;
    18 
    19                 public static function setUpBeforeClass() {
    20                         parent::setUpBeforeClass();
    21 
    22                         self::$original_site_blog_upload_space = get_site_option( 'blog_upload_space' );
    23                         self::$original_blog_upload_space      = get_option( 'blog_upload_space' );
    24                 }
    25 
    2616                public function setUp() {
    2717                        global $wpdb;
     
    3424                public function tearDown() {
    3525                        global $wpdb;
    36 
    37                         /**
    38                          * Reset the two `blog_upload_space` options to their original values so
    39                          * they can be relied on in other test classes.
    40                          */
    41                         update_site_option( 'blog_upload_space', self::$original_site_blog_upload_space );
    42                         update_option( 'blog_upload_space', self::$original_blog_upload_space );
    4326
    4427                        $wpdb->suppress_errors( $this->suppress );
  • trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php

    r48937 r50463  
    2727                        global $wpdb;
    2828
    29                         update_site_option( 'ms_files_rewriting', 0 );
    3029                        $wpdb->suppress_errors( $this->suppress );
    3130
  • trunk/tests/phpunit/tests/oembed/controller.php

    r50450 r50463  
    6565                $wp_rest_server = null;
    6666
    67                 remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10 );
    68                 remove_filter( 'oembed_result', array( $this, 'filter_oembed_result' ), 10 );
    6967                parent::tearDown();
    7068        }
  • trunk/tests/phpunit/tests/post/revisions.php

    r49603 r50463  
    2121        }
    2222
    23         function tearDown() {
    24                 unset( $GLOBALS['wp_post_types'][ $this->post_type ] );
    25                 parent::tearDown();
    26         }
    27 
    2823        /**
    2924         * Note: Test needs reviewing when #16215 is fixed because I'm not sure the test current tests the "correct" behavior
  • trunk/tests/phpunit/tests/query/isTerm.php

    r48937 r50463  
    6666        }
    6767
    68         function tearDown() {
    69                 global $wp_rewrite;
    70 
    71                 _unregister_taxonomy( 'testtax' );
    72 
    73                 $wp_rewrite->init();
    74 
    75                 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
    76                 parent::tearDown();
    77         }
    78 
    7968        function test_tag_action_tax() {
    8069                // Tag with taxonomy added.
  • trunk/tests/phpunit/tests/query/search.php

    r48939 r50463  
    1818
    1919        function tearDown() {
    20                 _unregister_post_type( $this->post_type );
    2120                unset( $this->q );
    2221
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r50450 r50463  
    9595                        unlink( $this->test_file2 );
    9696                }
    97 
    98                 remove_action( 'rest_insert_attachment', array( $this, 'filter_rest_insert_attachment' ) );
    99                 remove_action( 'rest_after_insert_attachment', array( $this, 'filter_rest_after_insert_attachment' ) );
    10097
    10198                $this->remove_added_uploads();
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r49922 r50463  
    11831183        }
    11841184
    1185         public function tearDown() {
    1186                 _unregister_taxonomy( 'batman' );
    1187                 _unregister_taxonomy( 'robin' );
    1188                 parent::tearDown();
    1189         }
    1190 
    11911185        protected function check_get_taxonomy_terms_response( $response ) {
    11921186                $this->assertSame( 200, $response->get_status() );
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r50024 r50463  
    765765        }
    766766
    767         public function tearDown() {
    768                 parent::tearDown();
    769                 remove_filter( 'theme_page_templates', array( $this, 'filter_theme_page_templates' ) );
    770         }
    771 
    772767        public function filter_theme_page_templates( $page_templates ) {
    773768                return array(
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r50284 r50463  
    50895089
    50905090        public function tearDown() {
    5091                 _unregister_post_type( 'private-post' );
    5092                 _unregister_post_type( 'youseeme' );
    50935091                if ( isset( $this->attachment_id ) ) {
    50945092                        $this->remove_added_uploads();
    50955093                }
    5096                 remove_filter( 'rest_pre_dispatch', array( $this, 'wpSetUpBeforeRequest' ), 10, 3 );
    5097                 remove_filter( 'posts_clauses', array( $this, 'save_posts_clauses' ), 10, 2 );
     5094
    50985095                parent::tearDown();
    50995096        }
  • trunk/tests/phpunit/tests/rest-api/rest-revisions-controller.php

    r49603 r50463  
    7575                $this->revision_3      = array_pop( $revisions );
    7676                $this->revision_id3    = $this->revision_3->ID;
    77         }
    78 
    79         public function tearDown() {
    80                 parent::tearDown();
    81 
    82                 remove_filter( 'map_meta_cap', array( $this, '_filter_map_meta_cap_remove_no_allow_revisions' ) );
    8377        }
    8478
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r50450 r50463  
    3232                $wp_rest_server = null;
    3333
    34                 remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 );
    3534                parent::tearDown();
    3635        }
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r49922 r50463  
    14011401        }
    14021402
    1403         public function tearDown() {
    1404                 _unregister_taxonomy( 'batman' );
    1405                 _unregister_taxonomy( 'robin' );
    1406                 parent::tearDown();
    1407         }
    1408 
    14091403        protected function check_get_taxonomy_terms_response( $response ) {
    14101404                $this->assertSame( 200, $response->get_status() );
  • trunk/tests/phpunit/tests/rewrite/numericSlugs.php

    r48937 r50463  
    1616        }
    1717
    18         public function tearDown() {
    19                 parent::tearDown();
    20                 remove_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ), 10, 6 );
    21         }
    22 
    2318        public function test_go_to_year_segment_collision_without_title() {
    2419                global $wpdb;
  • trunk/tests/phpunit/tests/rewrite/oldSlugRedirect.php

    r50450 r50463  
    3333                $this->old_slug_redirect_url = null;
    3434
    35                 remove_filter( 'old_slug_redirect_url', array( $this, 'filter_old_slug_redirect_url' ), 10 );
    3635                parent::tearDown();
    3736        }
  • trunk/tests/phpunit/tests/rewrite/rewriteTags.php

    r48939 r50463  
    88        protected $rewritereplace;
    99        protected $queryreplace;
    10         protected $wp_rewrite;
    1110
    1211        public function setUp() {
     
    1413                parent::setUp();
    1514
    16                 $this->wp_rewrite = $wp_rewrite;
    17                 $wp_rewrite       = new WP_Rewrite();
     15                $wp_rewrite = new WP_Rewrite();
    1816                $wp_rewrite->init();
    1917
     
    2119                $this->rewritereplace = $wp_rewrite->rewritereplace;
    2220                $this->queryreplace   = $wp_rewrite->queryreplace;
    23         }
    24 
    25         public function tearDown() {
    26                 global $wp_rewrite;
    27                 $wp_rewrite = $this->wp_rewrite;
    2821        }
    2922
  • trunk/tests/phpunit/tests/theme/WPTheme.php

    r48939 r50463  
    2121        function tearDown() {
    2222                $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
    23                 remove_filter( 'theme_root', array( $this, '_theme_root' ) );
    24                 remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
    25                 remove_filter( 'template_root', array( $this, '_theme_root' ) );
    2623                wp_clean_themes_cache();
    2724                unset( $GLOBALS['wp_themes'] );
  • trunk/tests/phpunit/tests/theme/themeDir.php

    r49566 r50463  
    2727        function tearDown() {
    2828                $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
    29                 remove_filter( 'theme_root', array( $this, '_theme_root' ) );
    30                 remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
    31                 remove_filter( 'template_root', array( $this, '_theme_root' ) );
    3229                wp_clean_themes_cache();
    3330                unset( $GLOBALS['wp_themes'] );
  • trunk/tests/phpunit/tests/user/author.php

    r49932 r50463  
    3838
    3939                setup_postdata( get_post( self::$post_id ) );
    40         }
    41 
    42         function tearDown() {
    43                 wp_reset_postdata();
    44                 parent::tearDown();
    4540        }
    4641
  • trunk/tests/phpunit/tests/user/countUserPosts.php

    r49603 r50463  
    5959        }
    6060
    61         public function tearDown() {
    62                 _unregister_post_type( 'wptests_pt' );
    63                 parent::tearDown();
    64         }
    65 
    6661        public function test_count_user_posts_post_type_should_default_to_post() {
    6762                $this->assertEquals( 4, count_user_posts( self::$user_id ) );
  • trunk/tests/phpunit/tests/user/wpSendUserRequest.php

    r49603 r50463  
    7777         */
    7878        public function tearDown() {
    79                 delete_option( 'WPLANG' );
    8079                reset_phpmailer_instance();
    8180
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPostType.php

    r49184 r50463  
    2222                );
    2323                register_post_type( $this->cpt_name, $this->cpt_args );
    24         }
    25 
    26         function tearDown() {
    27                 _unregister_post_type( $this->cpt_name );
    28 
    29                 parent::tearDown();
    3024        }
    3125
  • trunk/tests/phpunit/tests/xmlrpc/wp/getUser.php

    r48939 r50463  
    1616                        grant_super_admin( $this->administrator_id );
    1717                }
    18         }
    19 
    20         function tearDown() {
    21                 if ( is_multisite() ) {
    22                         revoke_super_admin( $this->administrator_id );
    23                 }
    24                 parent::tearDown();
    2518        }
    2619
Note: See TracChangeset for help on using the changeset viewer.