Skip to content

Tests: Add unit test coverage for WP_Site_Health::get_test_plugin_version() - #14582

Closed
huzaifaalmesbah wants to merge 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:tests/site-health-plugin-version
Closed

huzaifaalmesbah wants to merge 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:tests/site-health-plugin-version

Conversation

@huzaifaalmesbah

Copy link
Copy Markdown
Member

Description

Adds tests for WP_Site_Health::get_test_plugin_version(), the "Your plugins are all up to date" Site Health test. Only the case without active plugins is covered by an open PR (#13960); this PR leaves that case to it and covers the rest.

The tests prime the plugins cache with test plugins, set which are active, and add updates to the update_plugins transient. They cover:

  • the full good result for one active plugin and for several, with singular and plural sentences;
  • the critical result, its sentence and the network admin update link when one or more plugins have an update;
  • an update for a plugin that is not installed being ignored;
  • on single site, the recommended result, its sentence and the inactive plugins link for one or more inactive plugins;
  • on multisite, inactive plugins not being reported and only active plugins being counted.

Removing or changing each branch of the method makes at least one test fail on single site or multisite.

One case is left out: when plugins have updates and some plugins are inactive, the inactive check sets the status to recommended, replacing the critical status of the update check. That looks like a defect and can be handled in its own ticket.

This is a test-only change; no production code is modified.

Testing Instructions

  1. Run the tests on single site:
    npm run test:php -- --filter Tests_Admin_wpSiteHealthGetTestPluginVersion
  2. Run them on multisite:
    npm run test:php -- --filter Tests_Admin_wpSiteHealthGetTestPluginVersion -c tests/phpunit/multisite.xml
  3. Run them in random order:
    npm run test:php -- --filter Tests_Admin_wpSiteHealthGetTestPluginVersion --order-by=random
  4. Run the site health and plugins groups:
    npm run test:php -- --group site-health,plugins
  5. Run PHPCS on the test file:
    node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpcs tests/phpunit/tests/admin/wpSiteHealthGetTestPluginVersion.php

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Brainstorming edge-case scenarios and drafting test boilerplate; test architecture, assertions, and local PHPUnit verification were written and validated by me.

@huzaifaalmesbah
huzaifaalmesbah marked this pull request as ready for review October 20, 2026 21:15
@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 huzaifaalmesbah.

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

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 identified no blocking issues in the test-only changes; tests were not executed.

No open issues 🎉

What changed in this PR

Adds coverage for Site Health’s plugin-version check, complementing the zero-active-plugin case in #13960 without changing production code.

Changes:

  • Tests up-to-date, outdated, missing, and inactive plugin scenarios.
  • Verifies messages, action links, and single-site versus multisite behavior.
File Description
tests/​phpunit/​tests/​admin/​wpSiteHealthGetTestPluginVersion.php Adds plugin fixtures and assertions for plugin-version health results.

Review effort: Balanced

@huzaifaalmesbah

Copy link
Copy Markdown
Member Author

Small follow-up in af4abfe: the expected action links are now literal URLs instead of being built with esc_url() and admin_url() / network_admin_url(), the same calls the method makes.

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 identified no blocking correctness or isolation issues in this focused test-only change; tests were not executed.

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 refreshed assertions passed the unit-tests audit, targeted randomized single-site and multisite runs, and PHPCS. CI is green, and the fresh Copilot review found no blockers.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Oct 20, 2026
Test `WP_Site_Health::get_test_plugin_version()` for active and inactive plugins, available updates, singular and plural descriptions, update links, and multisite behavior.

Developed in: #14582

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64667 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 20, 2026
Test `WP_Site_Health::get_test_plugin_version()` for active and inactive plugins, available updates, singular and plural descriptions, update links, and multisite behavior.

Developed in: WordPress/wordpress-develop#14582

Props huzaifaalmesbah.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@63817 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.

3 participants