Skip to content

Tests: Add unit tests for wp_is_recovery_mode() - #14477

Closed
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:65819-add-wp-is-recovery-mode-tests
Closed

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:65819-add-wp-is-recovery-mode-tests

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What

Trac ticket: #65819

Adds unit tests for wp_is_recovery_mode() in tests/phpunit/tests/load/wpIsRecoveryMode.php.

Covers inactive and active recovery mode, and that the helper matches wp_recovery_mode()->is_active().

Test-only change.

Why

This helper has had no dedicated PHPUnit coverage.

How

  • Toggle the recovery mode singleton’s is_active state
  • Assert false when inactive, true when active
  • Confirm the helper matches WP_Recovery_Mode::is_active()

Testing instructions

npm run test:php -- --filter Tests_Load_WpIsRecoveryMode

Use of AI Tools

  • Cursor

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 cover the helper’s boolean behavior and restore shared state, with no blocking issues identified.

No open issues 🎉

What changed in this PR

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

Changes:

  • Tests inactive and active recovery mode.
  • Verifies agreement with the recovery-mode singleton.
  • Restores shared state after each test.
File Description
tests/​phpunit/​tests/​load/​wpIsRecoveryMode.php Adds helper tests with state setup and cleanup.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 19, 2026 08:43
@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.

* @param string $property Property name.
* @return mixed Property value.
*/
private function get_recovery_mode_property( $property ) {

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.

Optional, and it applies to several PRs in this series (#14482, #14480, #14477, #14476, #14475): each copies the same reflection helpers to read and set the recovery mode state. Also, tear_down() does not need to restore options or hooks. The test framework rolls back the database and restores hooks after each test.

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

Static review found no blocking issues in this focused test-only change; PHPUnit was not run.

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 literal active/inactive cases protect the wrapper’s result, and the singleton state is restored. Optional cleanup: remove test_matches_recovery_mode_singleton_state(); the two literal cases already cover both states with stronger expectations. Mukesh’s shared-helper suggestion can be handled separately.

Unit-tests audit and Copilot review found no blockers. PHPCS passed. Each class passed separately, and the combined batch passed randomized single-site and multisite runs: 63 tests, 95 assertions each (seeds 65829 and 65830). CI is green on the reviewed commit.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Oct 19, 2026
Verify active and inactive recovery-mode results and consistency with the recovery-mode instance. Restore its original state after each test.

Developed in: #14477

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64556 602fd350-edb4-49c9-b593-d223f7449a82
@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 19, 2026
Verify active and inactive recovery-mode results and consistency with the recovery-mode instance. Restore its original state after each test.

Developed in: WordPress/wordpress-develop#14477

Props shailu25, mukesh27.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@63706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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