Make WordPress Core

Changeset 64832


Ignore:
Timestamp:
10/27/2026 07:51:14 PM (33 hours ago)
Author:
lancewillett
Message:

Tests: Restore the active theme after comment tests.

Save the original stylesheet before switching themes in comment template, metadata cache, and comment list tests. Restore it during teardown.

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

Props devmuhib, huzaifaalmesbah.
See #65893.

Location:
trunk/tests/phpunit/tests/comment
Files:
3 edited

Legend:

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

    r64444 r64832  
    1111
    1212        /**
     13         * Original stylesheet.
     14         *
     15         * @var string
     16         */
     17        protected $original_stylesheet;
     18
     19        /**
    1320         * Performs setup tasks for every test.
    1421         */
    1522        public function set_up() {
    1623                parent::set_up();
     24                $this->original_stylesheet = get_stylesheet();
    1725                switch_theme( 'default' );
     26        }
     27
     28        /**
     29         * Cleans up after every test.
     30         */
     31        public function tear_down() {
     32                if ( get_stylesheet() !== $this->original_stylesheet ) {
     33                        switch_theme( $this->original_stylesheet );
     34                }
     35                parent::tear_down();
    1836        }
    1937
  • trunk/tests/phpunit/tests/comment/metaCache.php

    r60251 r64832  
    88
    99        /**
     10         * Original stylesheet.
     11         *
     12         * @var string
     13         */
     14        protected $original_stylesheet;
     15
     16        /**
    1017         * Performs setup tasks for every test.
    1118         */
    1219        public function set_up() {
    1320                parent::set_up();
     21                $this->original_stylesheet = get_stylesheet();
    1422                switch_theme( 'default' );
     23        }
     24
     25        /**
     26         * Cleans up after every test.
     27         */
     28        public function tear_down() {
     29                if ( get_stylesheet() !== $this->original_stylesheet ) {
     30                        switch_theme( $this->original_stylesheet );
     31                }
     32                parent::tear_down();
    1533        }
    1634
  • trunk/tests/phpunit/tests/comment/wpListComments.php

    r56635 r64832  
    99
    1010        /**
     11         * Original stylesheet.
     12         *
     13         * @var string
     14         */
     15        protected $original_stylesheet;
     16
     17        /**
    1118         * Performs setup tasks for every test.
    1219         */
    1320        public function set_up() {
    1421                parent::set_up();
     22                $this->original_stylesheet = get_stylesheet();
    1523                switch_theme( 'default' );
     24        }
     25
     26        /**
     27         * Cleans up after every test.
     28         */
     29        public function tear_down() {
     30                if ( get_stylesheet() !== $this->original_stylesheet ) {
     31                        switch_theme( $this->original_stylesheet );
     32                }
     33                parent::tear_down();
    1634        }
    1735
Note: See TracChangeset for help on using the changeset viewer.