Make WordPress Core

Changeset 64326


Ignore:
Timestamp:
10/13/2026 06:26:50 AM (4 hours ago)
Author:
lancewillett
Message:

Tests: Limit metadata registration in REST tags tests.

Register the five term metadata fields only in the tests that use them, instead of in every test in WP_Test_REST_Tags_Controller. Preserve the existing assertions and inherited setup and cleanup.

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

Props sainathpoojary.
See #66074.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r64233 r64326  
    7373        }
    7474
    75         public function set_up() {
    76                 parent::set_up();
    77 
     75        /**
     76         * Registers metadata fields for tests that exercise term metadata.
     77         */
     78        private function register_test_meta() {
    7879                register_meta(
    7980                        'term',
    … …  
    730731         */
    731732        public function test_get_item_meta() {
     733                $this->register_test_meta();
     734
    732735                $id = self::factory()->tag->create();
    733736
    … …  
    752755         */
    753756        public function test_get_item_meta_registered_for_different_taxonomy() {
     757                $this->register_test_meta();
     758
    754759                $id = self::factory()->tag->create();
    755760
    … …  
    870875
    871876        public function test_create_item_with_meta() {
     877                $this->register_test_meta();
     878
    872879                wp_set_current_user( self::$administrator );
    873880
    … …  
    885892
    886893        public function test_create_item_with_meta_wrong_id() {
     894                $this->register_test_meta();
     895
    887896                wp_set_current_user( self::$administrator );
    888897
    … …  
    904913
    905914        public function test_update_item() {
     915                $this->register_test_meta();
     916
    906917                wp_set_current_user( self::$administrator );
    907918
Note: See TracChangeset for help on using the changeset viewer.