From 7bebbbfe01f079a0427a665b7985d755e6b4cc4a Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 11:50:08 +0600 Subject: [PATCH 1/2] Tests: Cover wp_get_tooltip_helper(). See #65819. Props devmuhib009. --- .../tests/general/wpGetTooltipHelper.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/phpunit/tests/general/wpGetTooltipHelper.php diff --git a/tests/phpunit/tests/general/wpGetTooltipHelper.php b/tests/phpunit/tests/general/wpGetTooltipHelper.php new file mode 100644 index 0000000000000..ac55e40b26e10 --- /dev/null +++ b/tests/phpunit/tests/general/wpGetTooltipHelper.php @@ -0,0 +1,96 @@ +assertSame( '', wp_get_tooltip_helper( '' ) ); + $this->assertSame( '', wp_get_tooltip_helper( ' ' ) ); + } + + /** + * Tests default tooltip markup and attributes. + * + * @ticket 65819 + */ + public function test_wp_get_tooltip_helper_default_structure() { + $markup = wp_get_tooltip_helper( 'Help text content.' ); + + $this->assertStringContainsString( 'class="wp-tooltip wp-is-tooltip"', $markup ); + $this->assertStringContainsString( 'class="wp-tooltip__toggle"', $markup ); + $this->assertStringContainsString( 'class="dashicons dashicons-editor-help"', $markup ); + $this->assertStringContainsString( 'popover="hint"', $markup ); + $this->assertStringContainsString( 'role="tooltip"', $markup ); + $this->assertStringContainsString( 'class="wp-tooltip__text">Help text content.', $markup ); + } + + /** + * Tests toggletip type markup and attributes. + * + * @ticket 65819 + */ + public function test_wp_get_tooltip_helper_toggletip_type() { + $markup = wp_get_tooltip_helper( + 'Toggletip message', + array( + 'type' => 'toggletip', + 'label' => 'Information', + 'id' => 'my-toggletip', + ) + ); + + $this->assertStringContainsString( 'class="wp-tooltip wp-is-toggletip"', $markup ); + $this->assertStringContainsString( 'aria-haspopup="dialog"', $markup ); + $this->assertStringContainsString( 'popovertarget="my-toggletip"', $markup ); + $this->assertStringContainsString( 'id="my-toggletip"', $markup ); + } + + /** + * Tests using custom button markup. + * + * @ticket 65819 + */ + public function test_wp_get_tooltip_helper_custom_button() { + $custom_button = ''; + $markup = wp_get_tooltip_helper( + 'Help text', + array( + 'button' => $custom_button, + ) + ); + + $this->assertStringContainsString( 'class="my-custom-btn wp-tooltip__toggle"', $markup ); + } + + /** + * Tests custom class, id, and icon arguments. + * + * @ticket 65819 + */ + public function test_wp_get_tooltip_helper_custom_class_id_icon() { + $markup = wp_get_tooltip_helper( + 'Detailed explanation', + array( + 'id' => 'custom-help-id', + 'class' => 'extra-tooltip-style', + 'icon' => 'dashicons-info', + ) + ); + + $this->assertStringContainsString( 'extra-tooltip-style', $markup ); + $this->assertStringContainsString( 'id="custom-help-id"', $markup ); + $this->assertStringContainsString( 'dashicons dashicons-info', $markup ); + } +} From da1e230ea0c36a1332b898bd6d257c56a8e2f2f4 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 20:51:10 +0600 Subject: [PATCH 2/2] Tests: Cover wp_get_tooltip_helper(). See #66618. Props devmuhib009. --- tests/phpunit/tests/general/wpGetTooltipHelper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/general/wpGetTooltipHelper.php b/tests/phpunit/tests/general/wpGetTooltipHelper.php index ac55e40b26e10..def152fd4b7c9 100644 --- a/tests/phpunit/tests/general/wpGetTooltipHelper.php +++ b/tests/phpunit/tests/general/wpGetTooltipHelper.php @@ -13,7 +13,7 @@ class Tests_General_WpGetTooltipHelper extends WP_UnitTestCase { /** * Tests that empty or whitespace content returns an empty string. * - * @ticket 65819 + * @ticket 66618 */ public function test_wp_get_tooltip_helper_empty_content() { $this->assertSame( '', wp_get_tooltip_helper( '' ) ); @@ -23,7 +23,7 @@ public function test_wp_get_tooltip_helper_empty_content() { /** * Tests default tooltip markup and attributes. * - * @ticket 65819 + * @ticket 66618 */ public function test_wp_get_tooltip_helper_default_structure() { $markup = wp_get_tooltip_helper( 'Help text content.' ); @@ -39,7 +39,7 @@ public function test_wp_get_tooltip_helper_default_structure() { /** * Tests toggletip type markup and attributes. * - * @ticket 65819 + * @ticket 66618 */ public function test_wp_get_tooltip_helper_toggletip_type() { $markup = wp_get_tooltip_helper( @@ -60,7 +60,7 @@ public function test_wp_get_tooltip_helper_toggletip_type() { /** * Tests using custom button markup. * - * @ticket 65819 + * @ticket 66618 */ public function test_wp_get_tooltip_helper_custom_button() { $custom_button = ''; @@ -77,7 +77,7 @@ public function test_wp_get_tooltip_helper_custom_button() { /** * Tests custom class, id, and icon arguments. * - * @ticket 65819 + * @ticket 66618 */ public function test_wp_get_tooltip_helper_custom_class_id_icon() { $markup = wp_get_tooltip_helper(