From 0e9ff07da53f94d47ec6e1295fc0178752e13bb7 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 17 Feb 2016 23:01:05 +0000 Subject: [PATCH] Reintroduce term meta unit test accidentally removed in [36566]. git-svn-id: https://develop.svn.wordpress.org/trunk@36567 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/meta.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 1024881042..684dde41cb 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -150,6 +150,41 @@ class Tests_Term_Meta extends WP_UnitTestCase { } } + public function test_adding_term_meta_should_bust_get_terms_cache() { + $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + + add_term_meta( $terms[0], 'foo', 'bar' ); + + // Prime cache. + $found = get_terms( 'wptests_tax', array( + 'hide_empty' => false, + 'fields' => 'ids', + 'meta_query' => array( + array( + 'key' => 'foo', + 'value' => 'bar', + ), + ), + ) ); + + $this->assertEqualSets( array( $terms[0] ), $found ); + + add_term_meta( $terms[1], 'foo', 'bar' ); + + $found = get_terms( 'wptests_tax', array( + 'hide_empty' => false, + 'fields' => 'ids', + 'meta_query' => array( + array( + 'key' => 'foo', + 'value' => 'bar', + ), + ), + ) ); + + $this->assertEqualSets( array( $terms[0], $terms[1] ), $found ); + } + public function test_updating_term_meta_should_bust_get_terms_cache() { $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );