WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/17/2017 04:53:08 PM (5 years ago)
Author:
swissspidy
Message:

List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.

Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesListTable.php

    r39481 r40297  
    236236        $this->assertNotContains( 'id="cat"', $output );
    237237    }
     238
     239    /**
     240     * @ticket 38341
     241     */
     242    public function test_empty_trash_button_should_not_be_shown_if_there_are_no_posts() {
     243        // Set post type to a non-existent one.
     244        $this->table->screen->post_type = 'foo';
     245
     246        ob_start();
     247        $this->table->extra_tablenav( 'top' );
     248        $output = ob_get_clean();
     249
     250        $this->assertNotContains( 'id="delete_all"', $output );
     251    }
     252
     253    /**
     254     * @ticket 38341
     255     */
     256    public function test_empty_trash_button_should_not_be_shown_if_there_are_no_comments() {
     257        $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
     258
     259        ob_start();
     260        $table->extra_tablenav( 'top' );
     261        $output = ob_get_clean();
     262
     263        $this->assertNotContains( 'id="delete_all"', $output );
     264    }
    238265}
Note: See TracChangeset for help on using the changeset viewer.