Make WordPress Core


Ignore:
Timestamp:
10/21/2016 10:32:55 AM (9 years ago)
Author:
swissspidy
Message:

List Tables: Do not show filter button when there are no filter options available.

Props juhise, dipesh.kakadiya, swissspidy.
Fixes #37407.

File:
1 edited

Legend:

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

    r38398 r38854  
    99    protected static $grandchildren = array();
    1010    protected static $post_ids = array();
     11
     12    /**
     13     * @var WP_Posts_List_Table
     14     */
     15    protected $table;
    1116
    1217    function setUp() {
     
    192197    }
    193198
     199    /**
     200     * @ticket 37407
     201     */
     202    function test_filter_button_should_not_be_shown_if_there_are_no_posts() {
     203        // Set post type to a non-existent one.
     204        $this->table->screen->post_type = 'foo';
     205
     206        ob_start();
     207        $this->table->extra_tablenav( 'top' );
     208        $output = ob_get_clean();
     209
     210        $this->assertNotContains( 'id="post-query-submit"', $output );
     211    }
     212
     213    /**
     214     * @ticket 37407
     215     */
     216    function test_months_dropdown_should_not_be_shown_if_there_are_no_posts() {
     217        // Set post type to a non-existent one.
     218        $this->table->screen->post_type = 'foo';
     219
     220        ob_start();
     221        $this->table->extra_tablenav( 'top' );
     222        $output = ob_get_clean();
     223
     224        $this->assertNotContains( 'id="filter-by-date"', $output );
     225    }
     226
     227    /**
     228     * @ticket 37407
     229     */
     230    function test_category_dropdown_should_not_be_shown_if_there_are_no_posts() {
     231        // Set post type to a non-existent one.
     232        $this->table->screen->post_type = 'foo';
     233
     234        ob_start();
     235        $this->table->extra_tablenav( 'top' );
     236        $output = ob_get_clean();
     237
     238        $this->assertNotContains( 'id="cat"', $output );
     239    }
    194240}
Note: See TracChangeset for help on using the changeset viewer.