Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#65195 new enhancement

Tests: Add unit tests for wp_check_locked_posts()

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 wp_check_locked_posts() function in wp-admin/includes/misc.php. These tests ensure that the function correctly identifies locked posts, handles missing or invalid data in Heartbeat requests, and verifies that the correct user information (including avatars and collaboration status) is returned based on user permissions and site options.

Change History (2)

#1 @desrosj
5 weeks ago

  • Focuses tests added

Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.

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


5 weeks ago
#2

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the wp_check_locked_posts() function in wp-admin/includes/misc.php. These tests ensure that the function correctly identifies locked posts for the post list screen and returns the appropriate Heartbeat response data.

The tests cover:

  • Handling of empty or missing Heartbeat data.
  • Detection of locked posts when they are locked by other users.
  • Verification that no lock information is returned if the current user cannot edit the post.
  • Correct formatting of the response when collaboration (RTC) is enabled.
  • Correct inclusion of avatar URLs and user display names when collaboration is disabled.
  • Handling of invalid post keys.

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

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.