From c90037ca4776737e12b3fff2f0d18c68a4f12b42 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 23 Aug 2020 03:46:41 +0000 Subject: [PATCH] Tests: Clear any previous term IDs from the metadata lazyloader queue in term meta lazy-loading test. This fixes random test failures when one of the term IDs from previous tests coincides with the orphan term ID from this test that should not be lazy-loaded. Follow-up to [34529], [36566]. Fixes #51109. git-svn-id: https://develop.svn.wordpress.org/trunk@48844 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/meta.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 74c1e633f8..256ed19676 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -116,6 +116,9 @@ class Tests_Term_Meta extends WP_UnitTestCase { public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop() { global $wpdb; + // Clear any previous term IDs from the queue. + wp_metadata_lazyloader()->reset_queue( 'term' ); + $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); register_taxonomy( 'wptests_tax', 'post' ); @@ -157,6 +160,10 @@ class Tests_Term_Meta extends WP_UnitTestCase { } } + public static function set_cache_results( $q ) { + $q->set( 'cache_results', true ); + } + /** * @ticket 36593 */ @@ -473,10 +480,6 @@ class Tests_Term_Meta extends WP_UnitTestCase { $this->assertSame( array(), $meta ); } - public static function set_cache_results( $q ) { - $q->set( 'cache_results', true ); - } - /** * @ticket 38323 * @dataProvider data_register_term_meta