Skip to content

Tests: Add unit tests for wp_using_ext_object_cache() - #14452

Closed
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/65819-wp-using-ext-object-cache
Closed

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/65819-wp-using-ext-object-cache

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

What

Trac ticket: #65819

Adds unit tests for wp_using_ext_object_cache() in tests/phpunit/tests/load/wpUsingExtObjectCache.php.

Covers reading the current flag and setter behavior (returns previous value and updates $_wp_using_ext_object_cache).

Test-only change.

Why

This helper toggles external object cache usage across core and has had no dedicated PHPUnit coverage.

How

  • Cover get/set/idempotent updates; restore $_wp_using_ext_object_cache in tear_down

Testing instructions

npm run test:php -- --filter Tests_Load_WpUsingExtObjectCache

Use Of AI Tools

  • Cursor

Adds coverage for reading and toggling the external object cache flag.

See #65819.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The tests match the helper’s behavior, restore shared state, and have no identified blocking issues.

No open issues 🎉

What changed in this PR

Adds dedicated PHPUnit coverage for wp_using_ext_object_cache() without changing production code.

Changes:

  • Tests reading the flag, setter return values, and repeated updates.
  • Restores the original global flag during teardown to preserve test isolation.
File Description
tests/​phpunit/​tests/​load/​wpUsingExtObjectCache.php Adds getter, setter, and idempotency tests with global-state cleanup.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 18, 2026 09:17
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@rejaulalomkhan rejaulalomkhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @shail-mehta! Adding dedicated test coverage for wp_using_ext_object_cache() nicely covers the getter, setter return values, and idempotency behavior while preserving test isolation.

  • Tested locally on trunk across single-site, multisite, and random order (--order-by=random); all 3 tests and 15 assertions pass cleanly.
  • Verified --group load (44 tests, 56 assertions) passes with no regressions.
  • PHPCS check on tests/phpunit/tests/load/wpUsingExtObjectCache.php passes with 0 errors and 0 warnings.
  • Global state cleanup in tear_down() properly restores $_wp_using_ext_object_cache.

Looks good to merge!

AI Review: Antigravity

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused tests match the helper’s behavior and restore shared state, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests verify previous-value returns and state transitions while restoring the original external-cache flag. No blocking findings.

Unit-tests audit and Copilot review found no blockers. PHPCS passed all ten files. The combined batch passed locally in randomized order: single-site 149 tests / 283 assertions (seed 65825), multisite 140 tests / 236 assertions (seed 65826). CI is green on the reviewed commit.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Oct 19, 2026
Verify reading the external-cache flag, previous-value setter returns, state transitions, and repeated assignments. Restore the original flag after each test.

Developed in: #14452

Props shailu25, rejaulalomkhan.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64545 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 19, 2026
Verify reading the external-cache flag, previous-value setter returns, state transitions, and repeated assignments. Restore the original flag after each test.

Developed in: WordPress/wordpress-develop#14452

Props shailu25, rejaulalomkhan.
See #65819.

Built from https://develop.svn.wordpress.org/trunk@64545


git-svn-id: http://core.svn.wordpress.org/trunk@63695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@shail-mehta
shail-mehta deleted the tests/65819-wp-using-ext-object-cache branch October 21, 2026 09:06
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.

4 participants