Make WordPress Core

Changeset 65796


Ignore:
Timestamp:
11/25/2026 09:08:38 PM (11 hours ago)
Author:
lancewillett
Message:

Tests: Restore the rewrite object after rewrite tag tests.

Keep the sitemap rules registered at bootstrap available to subsequent canonical redirect tests.

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

Props mayankmajeji.
See #66755.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rewrite/rewriteTags.php

    r64507 r65796  
    99        protected $queryreplace;
    1010
     11        /**
     12         * The `WP_Rewrite` instance from before the test.
     13         *
     14         * @var WP_Rewrite
     15         */
     16        private $orig_wp_rewrite;
     17
    1118        public function set_up() {
    1219                global $wp_rewrite;
    1320                parent::set_up();
     21
     22                $this->orig_wp_rewrite = $wp_rewrite;
    1423
    1524                $wp_rewrite = new WP_Rewrite();
    … …  
    1928                $this->rewritereplace = $wp_rewrite->rewritereplace;
    2029                $this->queryreplace   = $wp_rewrite->queryreplace;
     30        }
     31
     32        public function tear_down() {
     33                $GLOBALS['wp_rewrite'] = $this->orig_wp_rewrite;
     34
     35                parent::tear_down();
    2136        }
    2237
Note: See TracChangeset for help on using the changeset viewer.