From 22fef7cf4b0ef6eb091c703e50178a95e5d4718a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 5 Feb 2014 03:49:48 +0000 Subject: [PATCH] Add a unit test demonstrating the failure to invalidate a post's term cache when the term is updated. See #22526. git-svn-id: https://develop.svn.wordpress.org/trunk@27099 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 465c635013..b90fbef735 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -567,4 +567,21 @@ class Tests_Term extends WP_UnitTestCase { // this previously returned 2 $this->assertEquals( 0, $count ); } + + /** + * @ticket 22526 + */ + function test_category_name_change() { + $term = $this->factory->category->create_and_get( array( 'name' => 'Foo' ) ); + $post_id = $this->factory->post->create(); + wp_set_post_categories( $post_id, $term->term_id ); + + $post = get_post( $post_id ); + $cats1 = get_the_category( $post->ID ); + $this->assertEquals( $term->name, reset( $cats1 )->name ); + + wp_update_term( $term->term_id, 'category', array( 'name' => 'Bar' ) ); + $cats2 = get_the_category( $post->ID ); + $this->assertNotEquals( $term->name, reset( $cats2 )->name ); + } }