Opened 6 months ago
Last modified 61 minutes ago
#65183 new enhancement
Tests: Add unit tests for set_screen_options()
| Reported by: | pbearne | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | tests |
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 (8)
This ticket was mentioned in PR #11739 on WordPress/wordpress-develop by @pbearne.
6 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
6 months ago
- Focuses tests added
Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.
@lancewillett commented on PR #11739:
8 days ago
#3
Pushed 988c2dd3830125fb064ae8703f5670da37255250 to remove the local die-handler overrides and ineffective nonce-action callbacks. The inherited test harness already supplies the terminal die handler; the requests create valid nonces. Redirect interception remains because the function exits after saving. No assertions changed.
The original and simplified tests both pass in randomized single-site and multisite runs: 7 cases and 7 assertions in each. The change removes 20 lines of setup/helpers. Fresh CI and review are still pending.
<sub>AI review · <code>gpt-6</code></sub>
@lancewillett commented on PR #11739:
8 days ago
#4
Follow-up in a10d314540544954b1b706921aa7e15ee08ec023: made the data provider static. It uses no instance state, so this follows PHPUnit’s provider requirements without changing the cases or assertions. Lint and PHPCS pass; randomized single-site and multisite runs each pass all seven tests and assertions.
<sub>AI review · <code>gpt-6</code></sub>
#5
@
8 days ago
- Milestone Awaiting Review → 7.2
PR #11739 now relies on the inherited die handler, removing duplicate setup and ineffective nonce-action callbacks. Its provider is static.
Its seven cases pass locally before and after the simplification in single-site and multisite. The tests protect saved/rejected screen-option metadata; invalid-nonce and redirect-destination coverage are not claimed. PHPCS and current-head CI pass, and the PR is approved.
@lancewillett commented on PR #11739:
8 days ago
#7
PR #11739 landed in https://core.trac.wordpress.org/changeset/65181
#8
@
61 minutes ago
- Component Administration → Build/Test Tools
Bulk edit: move all unit tests related tickets in milestone 7.2 to the Build/Test Tools component, to clear up the milestone.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Description:
This PR adds unit tests for the
set_screen_options()function inwp-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:
_per_pageoptions.set-screen-optionfilter.layout_columnsoptions.$_POSTdata.Trac ticket: https://core.trac.wordpress.org/ticket/65183
AI Disclosure: