From a6eec99e46ba3d27d69392fab90936cc36408e22 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 9 May 2022 00:32:39 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53368 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/taxonomy.php | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index a1d06c4691..de170de433 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -238,6 +238,58 @@ class Tests_Taxonomy extends WP_UnitTestCase { $this->assertSame( 3, $action->get_call_count() ); } + /** + * @ticket 49701 + * + * @covers ::get_inline_data + */ + public function test_get_inline_data_contains_term_if_show_ui_false_but_show_on_quick_edit_true_for_hierarchical_taxonomy() { + // Create a post with a term from a hierarchical taxonomy. + register_taxonomy( + 'wptests_tax_1', + 'post', + array( + 'show_ui' => false, + 'show_in_quick_edit' => true, + 'hierarchical' => true, + ) + ); + $term = wp_insert_term( 'Test', 'wptests_tax_1' ); + $post = self::factory()->post->create_and_get(); + wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' ); + + // Test get_inline_data() has post_category div containing assigned term. + wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) ); + get_inline_data( $post ); + $this->expectOutputRegex( '/
' . $term['term_id'] . '<\/div>/' ); + } + + /** + * @ticket 49701 + * + * @covers ::get_inline_data + */ + public function test_get_inline_data_contains_term_if_show_ui_false_but_show_on_quick_edit_true_for_nonhierarchical_taxonomy() { + // Create a post with a term from a hierarchical taxonomy. + register_taxonomy( + 'wptests_tax_1', + 'post', + array( + 'show_ui' => false, + 'show_in_quick_edit' => true, + 'hierarchical' => false, + ) + ); + $term = wp_insert_term( 'Test', 'wptests_tax_1' ); + $post = self::factory()->post->create_and_get(); + wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' ); + + // Test get_inline_data() has tags_input div containing assigned term. + wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) ); + get_inline_data( $post ); + $this->expectOutputRegex( '/
Test<\/div>/' ); + } + /** * @ticket 11058 */