Make WordPress Core

Changeset 65286


Ignore:
Timestamp:
11/05/2026 11:38:32 PM (34 hours ago)
Author:
lancewillett
Message:

Tests: Remove redundant registration cleanup from controller and admin tests.

WP_UnitTestCase_Base::set_up() resets post types, taxonomies, and non-built-in post statuses before each test. Per-test unregister calls added to these REST API, XML-RPC, admin, AJAX, and core registration tests repeated that reset, so remove them.

Keep scenario-specific unregister calls.

Follow-up to [64848], [64849], [64850], [64852], [64853], [64854], [64855], [64857], [65019], [65020], [65024].

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15190

Props peterwilsoncc.
See #65893.

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php

    r65044 r65286  
    160160                        wp_unregister_ability_category( $ability_category->get_slug() );
    161161                }
    162         }
    163 
    164         public function tear_down(): void {
    165                 unregister_post_type( 'not_viewable_pt' );
    166                 unregister_post_type( 'public_pt' );
    167                 unregister_post_type( 'private_pt' );
    168 
    169                 parent::tear_down();
    170162        }
    171163
  • trunk/tests/phpunit/tests/admin/exportWp.php

    r64849 r65286  
    9595        }
    9696
    97         public function tear_down() {
    98                 unregister_post_type( 'wpexport_excluded' );
    99 
    100                 parent::tear_down();
    101         }
    102 
    10397        /**
    10498         * @dataProvider data_should_include_attachments
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r65270 r65286  
    2525
    2626                self::$post_id = $factory->post->create();
    27         }
    28 
    29         public function tear_down() {
    30                 unregister_post_type( 'yes_title' );
    31                 unregister_post_type( 'no_title' );
    32 
    33                 parent::tear_down();
    3427        }
    3528
  • trunk/tests/phpunit/tests/admin/includesScreen.php

    r64848 r65286  
    158158        public function tear_down() {
    159159                unset( $GLOBALS['wp_taxonomies']['old-or-new'] );
    160                 unregister_post_type( 'value-add' );
    161                 unregister_post_type( 'edit-some-thing' );
    162                 unregister_post_type( 'comments' );
    163                 unregister_post_type( 'tags' );
    164                 unregister_post_type( 'type_shows_in_rest' );
    165 
    166160                parent::tear_down();
    167161        }
  • trunk/tests/phpunit/tests/admin/includesTemplate.php

    r64852 r65286  
    1313        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    1414                self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
    15         }
    16 
    17         public function tear_down() {
    18                 unregister_taxonomy( 'wptests_tax_1' );
    19 
    20                 parent::tear_down();
    2115        }
    2216
  • trunk/tests/phpunit/tests/ajax/wpAjaxInlineSave.php

    r64853 r65286  
    1414 */
    1515class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
    16 
    17         public function tear_down() {
    18                 unregister_taxonomy( 'wptests_tax_1' );
    19                 unregister_taxonomy( 'wptests_tax_2' );
    20 
    21                 parent::tear_down();
    22         }
    23 
    2416
    2517        /**
  • trunk/tests/phpunit/tests/ajax/wpCustomizeNavMenus.php

    r64855 r65286  
    8585                $this->wp_customize = new WP_Customize_Manager();
    8686                $wp_customize       = $this->wp_customize;
    87         }
    88 
    89         public function tear_down() {
    90                 unregister_post_type( 'privilege' );
    91 
    92                 parent::tear_down();
    9387        }
    9488
  • trunk/tests/phpunit/tests/entity-actions/registerCoreEntityActions.php

    r64894 r65286  
    106106         */
    107107        public function tear_down() {
    108                 unregister_post_type( 'test_book' );
    109                 unregister_post_type( 'test_note' );
    110                 unregister_post_type( 'test_hidden' );
    111 
    112108                self::reset_registry();
    113109
  • trunk/tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php

    r65007 r65286  
    6464         */
    6565        public function tear_down() {
    66                 unregister_post_type( 'test_book' );
    67                 unregister_post_type( 'test_note' );
    68 
    6966                global $_wp_theme_features;
    7067
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r65024 r65286  
    103103                        )
    104104                );
    105         }
    106 
    107         public function tear_down() {
    108                 unregister_taxonomy( 'batman' );
    109                 unregister_taxonomy( 'robin' );
    110 
    111                 parent::tear_down();
    112105        }
    113106
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r65192 r65286  
    99 */
    1010class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcase {
    11 
    12         public function tear_down() {
    13                 unregister_post_type( 'cpt' );
    14                 unregister_post_type( 'cpt_template' );
    15 
    16                 parent::tear_down();
    17         }
    1811
    1912        public function test_register_routes() {
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r65024 r65286  
    7171                        wp_delete_term( $tag_id, 'post_tag' );
    7272                }
    73         }
    74 
    75         public function tear_down() {
    76                 unregister_taxonomy( 'batman' );
    77                 unregister_taxonomy( 'robin' );
    78 
    79                 parent::tear_down();
    8073        }
    8174
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r65020 r65286  
    2222        public static function wpTearDownAfterClass() {
    2323                self::delete_user( self::$contributor_id );
    24         }
    25 
    26         public function tear_down() {
    27                 unregister_taxonomy( 'api-private' );
    28                 unregister_taxonomy( 'test' );
    29                 unregister_taxonomy_for_object_type( 'category', 'attachment' );
    30 
    31                 parent::tear_down();
    3224        }
    3325
  • trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php

    r65024 r65286  
    2525                        )
    2626                );
    27         }
    28 
    29         public function tear_down() {
    30                 unregister_taxonomy( 'wptests_tax' );
    31                 parent::tear_down();
    3227        }
    3328
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPostType.php

    r65024 r65286  
    2222                );
    2323                register_post_type( $this->cpt_name, $this->cpt_args );
    24         }
    25 
    26         public function tear_down() {
    27                 unregister_post_type( $this->cpt_name );
    28                 parent::tear_down();
    2924        }
    3025
  • trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php

    r65019 r65286  
    55 */
    66class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase {
    7 
    8         public function tear_down() {
    9                 unregister_taxonomy( 'wp_getTerms_custom_taxonomy' );
    10                 parent::tear_down();
    11         }
    127
    138        public function test_invalid_username_password() {
Note: See TracChangeset for help on using the changeset viewer.