Comments: Don't show the filter/pagination actions if there are no comments to list.

It doesn't make sense to be able to filter the comments list table when there are are no (trashed/spam) comments available.

Fixes #40188.
Props swissspidy, Jim_Panse, menakas, akbarhusen429, dinhtungdu, birgire, SergeyBiryukov, davidbaumwald, rebasaurus, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48521 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-07-21 00:27:46 +00:00
parent 5674e7e085
commit 4ba60208d4
2 changed files with 124 additions and 30 deletions

View File

@@ -281,6 +281,64 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
$this->assertNotContains( 'id="delete_all"', $output );
}
/**
* @ticket 40188
*/
public function test_filter_button_should_not_be_shown_if_there_are_no_comments() {
$table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
ob_start();
$table->extra_tablenav( 'top' );
$output = ob_get_clean();
$this->assertNotContains( 'id="post-query-submit"', $output );
}
/**
* @ticket 40188
*/
public function test_filter_button_should_be_shown_if_there_are_comments() {
$post_id = self::factory()->post->create();
$comment_id = self::factory()->comment->create(
array(
'comment_post_ID' => $post_id,
'comment_approved' => '1',
)
);
$table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
$table->prepare_items();
ob_start();
$table->extra_tablenav( 'top' );
$output = ob_get_clean();
$this->assertContains( 'id="post-query-submit"', $output );
}
/**
* @ticket 40188
*/
public function test_filter_comment_status_dropdown_should_be_shown_if_there_are_comments() {
$post_id = self::factory()->post->create();
$comment_id = self::factory()->comment->create(
array(
'comment_post_ID' => $post_id,
'comment_approved' => '1',
)
);
$table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
$table->prepare_items();
ob_start();
$table->extra_tablenav( 'top' );
$output = ob_get_clean();
$this->assertContains( 'id="filter-by-comment-type"', $output );
$this->assertContains( "<option value='comment'>", $output );
}
/**
* @ticket 38341
*/