Add tests demonstrating individual comment cache invalidation.

See #36906.

git-svn-id: https://develop.svn.wordpress.org/trunk@37609 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2016-06-01 17:15:27 +00:00
parent 425fffeb4f
commit 04d01a8eb4
1 changed files with 78 additions and 0 deletions

View File

@ -687,4 +687,82 @@ class Tests_Comment extends WP_UnitTestCase {
$this->assertSame( $expected[ $field ], $length );
}
}
public function test_update_should_invalidate_comment_cache() {
global $wpdb;
$c = self::factory()->comment->create( array( 'comment_author' => 'Foo' ) );
$comment = get_comment( $c );
$this->assertSame( 'Foo', $comment->comment_author );
wp_update_comment( array(
'comment_ID' => $c,
'comment_author' => 'Bar',
) );
$comment = get_comment( $c );
$this->assertSame( 'Bar', $comment->comment_author );
}
public function test_trash_should_invalidate_comment_cache() {
global $wpdb;
$c = self::factory()->comment->create();
$comment = get_comment( $c );
wp_trash_comment( $c );
$comment = get_comment( $c );
$this->assertSame( 'trash', $comment->comment_approved );
}
public function test_untrash_should_invalidate_comment_cache() {
global $wpdb;
$c = self::factory()->comment->create();
wp_trash_comment( $c );
$comment = get_comment( $c );
$this->assertSame( 'trash', $comment->comment_approved );
wp_untrash_comment( $c );
$comment = get_comment( $c );
$this->assertSame( '1', $comment->comment_approved );
}
public function test_spam_should_invalidate_comment_cache() {
global $wpdb;
$c = self::factory()->comment->create();
$comment = get_comment( $c );
wp_spam_comment( $c );
$comment = get_comment( $c );
$this->assertSame( 'spam', $comment->comment_approved );
}
public function test_unspam_should_invalidate_comment_cache() {
global $wpdb;
$c = self::factory()->comment->create();
wp_spam_comment( $c );
$comment = get_comment( $c );
$this->assertSame( 'spam', $comment->comment_approved );
wp_unspam_comment( $c );
$comment = get_comment( $c );
$this->assertSame( '1', $comment->comment_approved );
}
}