Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#65183 new enhancement

Tests: Add unit tests for set_screen_options()

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 unit tests for the set_screen_options() function in wp-admin/includes/misc.php. The tests will cover saving screen options, handling missing or invalid data, and verifying user authentication and nonce checks.

Change History (2)

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


6 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the set_screen_options() function in wp-admin/includes/misc.php. These tests ensure that the function correctly saves screen options (like items per page) for the current user, handles non-standard options via filters, and correctly validates input ranges.

The tests cover:

  • Saving standard _per_page options.
  • Saving custom options using the set-screen-option filter.
  • Handling layout_columns options.
  • Validating that values are within the allowed range (1-999).
  • Correct handling of missing or invalid $_POST data.
  • Ensuring the function correctly performs nonce and referer checks.

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

AI Disclosure:

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

#2 @desrosj
5 weeks ago

  • Focuses tests added

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

Note: See TracTickets for help on using tickets.