From 7359a917f94381c9c6fc94a0e300c1ca7f494486 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 11:46:41 +0600 Subject: [PATCH 1/2] Tests: Cover wp_heartbeat_settings(). See #65819. Props devmuhib009. --- .../tests/general/wpHeartbeatSettings.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/phpunit/tests/general/wpHeartbeatSettings.php diff --git a/tests/phpunit/tests/general/wpHeartbeatSettings.php b/tests/phpunit/tests/general/wpHeartbeatSettings.php new file mode 100644 index 0000000000000..41bb67b1c5aa0 --- /dev/null +++ b/tests/phpunit/tests/general/wpHeartbeatSettings.php @@ -0,0 +1,61 @@ + 60 ); + $settings = wp_heartbeat_settings( $initial ); + + $this->assertSame( 60, $settings['interval'] ); + $this->assertSame( admin_url( 'admin-ajax.php', 'relative' ), $settings['ajaxurl'] ); + $this->assertArrayNotHasKey( 'nonce', $settings ); + } + + /** + * Tests frontend logged-in settings behavior with valid nonce. + * + * @ticket 65819 + */ + public function test_wp_heartbeat_settings_frontend_logged_in() { + $user_id = self::factory()->user->create(); + wp_set_current_user( $user_id ); + + $settings = wp_heartbeat_settings( array() ); + + $this->assertArrayHasKey( 'nonce', $settings ); + $this->assertNotFalse( wp_verify_nonce( $settings['nonce'], 'heartbeat-nonce' ) ); + $this->assertSame( admin_url( 'admin-ajax.php', 'relative' ), $settings['ajaxurl'] ); + } + + /** + * Tests that existing settings are preserved. + * + * @ticket 65819 + */ + public function test_wp_heartbeat_settings_preserves_custom_settings() { + wp_set_current_user( 0 ); + + $custom = array( + 'interval' => 15, + 'customKey' => 'customValue', + ); + $settings = wp_heartbeat_settings( $custom ); + + $this->assertSame( 15, $settings['interval'] ); + $this->assertSame( 'customValue', $settings['customKey'] ); + } +} From 8662d1a917750145a15f020640a4362850187b56 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 20:50:58 +0600 Subject: [PATCH 2/2] Tests: Cover wp_heartbeat_settings(). See #66614. Props devmuhib009. --- tests/phpunit/tests/general/wpHeartbeatSettings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/general/wpHeartbeatSettings.php b/tests/phpunit/tests/general/wpHeartbeatSettings.php index 41bb67b1c5aa0..94169da433499 100644 --- a/tests/phpunit/tests/general/wpHeartbeatSettings.php +++ b/tests/phpunit/tests/general/wpHeartbeatSettings.php @@ -12,7 +12,7 @@ class Tests_General_WpHeartbeatSettings extends WP_UnitTestCase { /** * Tests frontend logged-out settings behavior. * - * @ticket 65819 + * @ticket 66614 */ public function test_wp_heartbeat_settings_frontend_logged_out() { wp_set_current_user( 0 ); @@ -28,7 +28,7 @@ public function test_wp_heartbeat_settings_frontend_logged_out() { /** * Tests frontend logged-in settings behavior with valid nonce. * - * @ticket 65819 + * @ticket 66614 */ public function test_wp_heartbeat_settings_frontend_logged_in() { $user_id = self::factory()->user->create(); @@ -44,7 +44,7 @@ public function test_wp_heartbeat_settings_frontend_logged_in() { /** * Tests that existing settings are preserved. * - * @ticket 65819 + * @ticket 66614 */ public function test_wp_heartbeat_settings_preserves_custom_settings() { wp_set_current_user( 0 );