Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#65201 new enhancement

Tests: Add unit tests for heartbeat_autosave()

Reported by: pbearne's profile pbearne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: tests Cc:

Description

This ticket adds comprehensive unit tests for the heartbeat_autosave() function in wp-admin/includes/misc.php. These tests will verify that the function correctly triggers wp_autosave() and returns the appropriate Heartbeat response for success, error, and empty states.

Change History (1)

This ticket was mentioned in PR #11762 on WordPress/wordpress-develop by @pbearne.


5 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the heartbeat_autosave() function in wp-admin/includes/misc.php. These tests ensure that the function correctly processes Heartbeat data to trigger post autosaves, and returns the appropriate response messages for success, error, and empty states.

The tests cover:

  • Verification that the response remains unchanged if no wp_autosave data is provided.
  • Successful autosave with correct success message and date format.
  • Handling of WP_Error returned by wp_autosave().
  • Handling of empty results (e.g., when content/title are empty).

Trac ticket: https://core.trac.wordpress.org/ticket/65201

AI Disclosure:

  • AI assistance: Yes
  • Tool(s): Junie (JetBrains)
  • Model(s): gemini-3-flash-preview
  • Used for: Code analysis, test implementation, and workflow management.
Note: See TracTickets for help on using tickets.