@@ -46,6 +46,43 @@ public function test_using_filter_adjusts_comment_count_without_an_additional_da
4646 remove_filter ( 'pre_wp_update_comment_count_now ' , array ( $ this , '_return_100 ' ) );
4747 }
4848
49+ /**
50+ * @ticket 64325
51+ */
52+ public function test_only_approved_regular_comments_are_counted () {
53+ $ post_id = self ::factory ()->post ->create ();
54+
55+ self ::factory ()->comment ->create (
56+ array (
57+ 'comment_post_ID ' => $ post_id ,
58+ 'comment_approved ' => 0 ,
59+ )
60+ );
61+ self ::factory ()->comment ->create (
62+ array (
63+ 'comment_post_ID ' => $ post_id ,
64+ 'comment_approved ' => 1 ,
65+ )
66+ );
67+ self ::factory ()->comment ->create (
68+ array (
69+ 'comment_post_ID ' => $ post_id ,
70+ 'comment_type ' => 'note ' ,
71+ 'comment_approved ' => 0 ,
72+ )
73+ );
74+ self ::factory ()->comment ->create (
75+ array (
76+ 'comment_post_ID ' => $ post_id ,
77+ 'comment_type ' => 'note ' ,
78+ 'comment_approved ' => 1 ,
79+ )
80+ );
81+
82+ $ this ->assertTrue ( wp_update_comment_count_now ( $ post_id ) );
83+ $ this ->assertSame ( '1 ' , get_comments_number ( $ post_id ) );
84+ }
85+
4986 public function _return_100 () {
5087 return 100 ;
5188 }
0 commit comments