Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/phpunit/tests/general/wpHeartbeatSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,21 @@ public function test_wp_heartbeat_settings_preserves_custom_settings() {
$this->assertSame( 15, $settings['interval'] );
$this->assertSame( 'customValue', $settings['customKey'] );
}

/**
* Tests that admin requests do not get an `ajaxurl`, but logged-in users still get a nonce.
*
* Admin screens define `ajaxurl` themselves.
*
* @ticket 66820
*/
public function test_wp_heartbeat_settings_admin() {
wp_set_current_user( self::factory()->user->create() );
set_current_screen( 'dashboard' );

$settings = wp_heartbeat_settings( array() );

$this->assertArrayNotHasKey( 'ajaxurl', $settings, 'Admin requests should not get an ajaxurl.' );
$this->assertNotFalse( wp_verify_nonce( $settings['nonce'] ?? '', 'heartbeat-nonce' ), 'Logged-in admin requests should get a valid nonce.' );
}
}
Loading