Make WordPress Core

Changeset 53368


Ignore:
Timestamp:
05/09/2022 12:32:39 AM (4 years ago)
Author:
peterwilsoncc
Message:

Quick/Bulk Edit: Additional tests for showing taxonomies.

Additional tests to ensure taxonomies show in the quick/bulk edit froms based on the show_in_quick_edit setting rather than the the show_ui setting.

Follow up to [52841,31307].

Props figureone, costdev, audrasjb.
Fixes #49701.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/taxonomy.php

    r53126 r53368  
    240240
    241241        /**
     242         * @ticket 49701
     243         *
     244         * @covers ::get_inline_data
     245         */
     246        public function test_get_inline_data_contains_term_if_show_ui_false_but_show_on_quick_edit_true_for_hierarchical_taxonomy() {
     247                // Create a post with a term from a hierarchical taxonomy.
     248                register_taxonomy(
     249                        'wptests_tax_1',
     250                        'post',
     251                        array(
     252                                'show_ui'            => false,
     253                                'show_in_quick_edit' => true,
     254                                'hierarchical'       => true,
     255                        )
     256                );
     257                $term = wp_insert_term( 'Test', 'wptests_tax_1' );
     258                $post = self::factory()->post->create_and_get();
     259                wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' );
     260
     261                // Test get_inline_data() has post_category div containing assigned term.
     262                wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     263                get_inline_data( $post );
     264                $this->expectOutputRegex( '/<div class="post_category" id="wptests_tax_1_' . $post->ID . '">' . $term['term_id'] . '<\/div>/' );
     265        }
     266
     267        /**
     268         * @ticket 49701
     269         *
     270         * @covers ::get_inline_data
     271         */
     272        public function test_get_inline_data_contains_term_if_show_ui_false_but_show_on_quick_edit_true_for_nonhierarchical_taxonomy() {
     273                // Create a post with a term from a hierarchical taxonomy.
     274                register_taxonomy(
     275                        'wptests_tax_1',
     276                        'post',
     277                        array(
     278                                'show_ui'            => false,
     279                                'show_in_quick_edit' => true,
     280                                'hierarchical'       => false,
     281                        )
     282                );
     283                $term = wp_insert_term( 'Test', 'wptests_tax_1' );
     284                $post = self::factory()->post->create_and_get();
     285                wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' );
     286
     287                // Test get_inline_data() has tags_input div containing assigned term.
     288                wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     289                get_inline_data( $post );
     290                $this->expectOutputRegex( '/<div class="tags_input" id="wptests_tax_1_' . $post->ID . '">Test<\/div>/' );
     291        }
     292
     293        /**
    242294         * @ticket 11058
    243295         */
Note: See TracChangeset for help on using the changeset viewer.