From 5c19fa13699e409fd11b37db3af9b4bc440bcf7e Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 20 Aug 2024 20:05:21 +0000 Subject: [PATCH] Tests: Remove WP_Term::$filter property unset() within term tests. Removes the `unset()` of the `WP_Term::$filter` property within the term tests. Why? Prior to the introduction of WP_Term, the term was added to the cache when its filter property was empty. To test the cache, the tests unset this property to trigger `wp_cache_add()` in `get_term()`. [34997] changed that behavior to trigger `wp_cache_add()` when the term was not found after `wp_cache_get()` (i.e. happened in `WP_Term::get_instance()`). Unsetting the filter property is and was not needed. Prior to `WP_Term`, the condition was an empty value. With `WP_Term`, the filter property is no longer part of the conditional logic for caching. Follow-up to [34997], [30954], [34035]. See #61890, #61530. git-svn-id: https://develop.svn.wordpress.org/trunk@58919 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/cache.php | 3 --- tests/phpunit/tests/term/getTerm.php | 1 - 2 files changed, 4 deletions(-) diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 0651551f941e9..f299bf9bed643 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -116,9 +116,6 @@ public function test_get_term_should_update_term_cache_when_passed_an_object() { $num_queries = get_num_queries(); - // get_term() will only be update the cache if the 'filter' prop is unset. - unset( $term_object->filter ); - $term_object_2 = get_term( $term_object, 'wptests_tax' ); // No new queries should have fired. diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index ed6acab691fc5..a72ebca40ad40 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -98,7 +98,6 @@ public function test_passing_term_object_should_skip_database_query_when_filter_ $num_queries = get_num_queries(); - unset( $term->filter ); $term_a = get_term( $term, 'wptests_tax' ); $this->assertSame( $num_queries, get_num_queries() );