diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 29343f78a0f6d..4903d8678faf9 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -151,6 +151,7 @@ public function prepare_items() { 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, + 'type__not_in' => array( 'note' ), 'orderby' => $orderby, 'order' => $order, 'post_type' => $post_type, diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index ed1d3a83bfb38..20c2c1986f79c 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -218,10 +218,15 @@ public function test_get_views_should_return_views_by_default() { * Verify that the comments table never shows the note comment_type. * * @ticket 64198 + * @ticket 64474 + * + * @dataProvider data_comment_type + * + * @param string $comment_type The comment_type parameter value to test. */ - public function test_comments_list_table_does_not_show_note_comment_type() { - $post_id = self::factory()->post->create(); - $note_id = self::factory()->comment->create( + public function test_comments_list_table_does_not_show_note_comment_type( string $comment_type ) { + $post_id = self::factory()->post->create(); + self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'comment_content' => 'This is a note.', @@ -229,7 +234,7 @@ public function test_comments_list_table_does_not_show_note_comment_type() { 'comment_approved' => '1', ) ); - $comment_id = self::factory()->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'comment_content' => 'This is a regular comment.', @@ -237,11 +242,22 @@ public function test_comments_list_table_does_not_show_note_comment_type() { 'comment_approved' => '1', ) ); - // Request the note comment type. - $_REQUEST['comment_type'] = 'note'; + $_REQUEST['comment_type'] = $comment_type; $this->table->prepare_items(); $items = $this->table->items; $this->assertCount( 1, $items ); $this->assertEquals( $comment_id, $items[0]->comment_ID ); } + + /** + * Data provider for test_comments_list_table_does_not_show_note_comment_type(). + * + * @return array + */ + public function data_comment_type(): array { + return array( + 'note type explicitly requested' => array( 'note' ), + 'all type requested' => array( 'all' ), + ); + } }