Make WordPress Core

Changeset 64016


Ignore:
Timestamp:
09/30/2026 03:39:47 PM (13 hours ago)
Author:
lancewillett
Message:

Tests: Improve isolation for randomized query tests.

Save and restore the sticky_posts option around the sticky-query test class to prevent its shared fixtures from affecting other tests.

Regenerate canonical rewrite rules after registering the initial taxonomies, and use the recognized ID orderby value to select child posts deterministically.

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

Props jonsurrell, adrianmoldovanwp.
See #65893.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-canonical.php

    r61136 r64016  
    3333                $this->set_permalink_structure( $this->structure );
    3434                create_initial_taxonomies();
     35                flush_rewrite_rules( false );
    3536        }
    3637
  • trunk/tests/phpunit/tests/query/stickies.php

    r55822 r64016  
    99class Tests_Query_Stickies extends WP_UnitTestCase {
    1010        public static $posts = array();
     11        private static $original_sticky_posts;
    1112
    1213        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     14                self::$original_sticky_posts = get_option( 'sticky_posts' );
     15                update_option( 'sticky_posts', array() );
     16
    1317                // Set post times to get a reliable order.
    1418                $now = time();
    … …  
    2529                stick_post( self::$posts[14] );
    2630                stick_post( self::$posts[8] );
     31        }
     32
     33        public static function wpTearDownAfterClass() {
     34                update_option( 'sticky_posts', self::$original_sticky_posts );
    2735        }
    2836
  • trunk/tests/phpunit/tests/query/thePost.php

    r61038 r64016  
    111111                                'post_type' => 'page',
    112112                                'post__in'  => self::$page_child_ids,
    113                                 'orderby'   => 'id',
     113                                'orderby'   => 'ID',
    114114                                'order'     => 'ASC',
    115115                        )
Note: See TracChangeset for help on using the changeset viewer.