Skip to content

Tests: Use the autoload constants in the option tests - #15679

Draft
wjrosa wants to merge 2 commits into
WordPress:trunkfrom
wjrosa:enhancement/option-autoload-constants-tests
Draft

wjrosa wants to merge 2 commits into
WordPress:trunkfrom
wjrosa:enhancement/option-autoload-constants-tests

Conversation

@wjrosa

@wjrosa wjrosa commented Nov 6, 2026

Copy link
Copy Markdown

Follow-up to #15567. That PR adds the WP_Option_Autoload constants. This PR uses them in the option tests.

This PR depends on #15567. Its first commit is the commit from that PR. Review only the second commit.

Rules used:

  • Use the constants for expected values (what the code stores or returns) and for the current values passed in ('on', 'off', 'auto', 'auto-on', 'auto-off').
  • Keep 'yes' and 'no' as plain strings where tests pass them in. These tests check backward compatibility for plugins that still send the raw strings, so they must keep sending the raw strings.
  • Keep the data provider keys and docblocks as they are.

If a constant gets the wrong value by mistake, the tests that use it would still pass. Tests_Option_wpOptionAutoload, added in #15567, catches that: it checks each constant against the exact string stored in the database.

Trac ticket:

Testing instructions

This PR only changes tests.

Setup: Node 24.18 or newer, and Docker running.

  1. From the repository root, run:
    cp .env.example .env
    npm ci
    npm run env:start
    npm run env:install
    
  2. Run the option tests:
    npm run test:php -- --group option
    
    Expected: no failures, and the same test and assertion counts as on the Options: Add constants for the option autoload values #15567 branch.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Converting the test values and drafting this description. I reviewed the changes and ran the tests.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with Claude Code

wjrosa and others added 2 commits November 5, 2026 19:11
Introduces the `WP_Option_Autoload` class, which holds the values stored in the `autoload` column of the options table, and uses it in the Option API instead of repeating the strings.

There is no change in behavior: the stored values, return values and filters stay the same strings.

Follow-up to [57920], [58105].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKNCpEmZxEKHTbyKtmgpzZ
Uses the `WP_Option_Autoload` constants for expected values and for current input values. The legacy 'yes' and 'no' inputs stay as plain strings, since those tests check backward compatibility.

Follow-up to [58105].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKNCpEmZxEKHTbyKtmgpzZ
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant