Make WordPress Core

Ticket #37407: 37407.7.diff

File 37407.7.diff, 2.9 KB (added by dipesh.kakadiya, 9 years ago)

minor typo 'are_now_posts' => 'are_not_posts' for testing functions

  • src/wp-admin/includes/class-wp-posts-list-table.php

     
    459459                <div class="alignleft actions">
    460460<?php
    461461                if ( 'top' === $which && !is_singular() ) {
     462                        ob_start();
    462463
    463464                        $this->months_dropdown( $this->screen->post_type );
    464465                        $this->categories_dropdown( $this->screen->post_type );
     
    479480                         */
    480481                        do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
    481482
    482                         submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
     483                        $output = ob_get_clean();
     484
     485                        if ( ! empty( $output ) ) {
     486                                echo $output;
     487                                submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
     488                        }
    483489                }
    484490
    485491                if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
     
    15521558        <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
    15531559                <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
    15541560                        $taxonomy_name = esc_attr( $taxonomy->name );
    1555        
     1561
    15561562                        ?>
    15571563                        <label class="inline-edit-tags">
    15581564                                <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
  • tests/phpunit/tests/admin/includesListTable.php

     
    99        protected static $grandchildren = array();
    1010        protected static $post_ids = array();
    1111
     12        /**
     13         * @var WP_Posts_List_Table
     14         */
     15        protected $table;
     16
    1217        function setUp() {
    1318                parent::setUp();
    1419                set_current_screen( 'edit-page' );
     
    191196                }
    192197        }
    193198
     199        /**
     200         * @ticket 37407
     201         */
     202        function test_filter_button_should_not_be_shown_if_there_are_not_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_not_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_not_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}