Skip to content

Tests: Add unit test coverage for the plugin sections of WP_Debug_Data - #14583

Closed
huzaifaalmesbah wants to merge 1 commit into
WordPress:trunkfrom
huzaifaalmesbah:tests/debug-data-plugins
Closed

huzaifaalmesbah wants to merge 1 commit into
WordPress:trunkfrom
huzaifaalmesbah:tests/debug-data-plugins

Conversation

@huzaifaalmesbah

Copy link
Copy Markdown
Member

Description

Adds tests for WP_Debug_Data::get_wp_mu_plugins() and WP_Debug_Data::get_wp_plugins_raw_data(), which build the "Must Use Plugins", "Active Plugins" and "Inactive Plugins" sections of the Site Health Info screen and the copied debug data. Neither method had tests.

The tests move the must-use plugins directory aside and create must-use plugins in it, prime the plugins cache with test plugins, and set the update_plugins transient and the auto-update settings. They cover:

  • the empty "Must Use Plugins" section;
  • the value and debug strings for a version and author, an author only, a version only, or neither, for must-use plugins and for active and inactive plugins;
  • fields keyed by the sanitized plugin name, with the raw name as the label;
  • the latest version being added when an update is available;
  • no auto-update status, and no auto-update filter call, while plugin auto-updates are disabled;
  • the auto-update status from the auto_update_plugins setting, and the auto_update_plugin filter forcing it on or off;
  • the update item passed to that filter coming from the available updates, the plugins without updates, or the plugin data when the plugin was not checked yet;
  • the plugin_auto_update_debug_string filter receiving its arguments and changing the status string.

Removing or changing each branch of the two methods makes at least one test fail.

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_wpDebugDataPlugins
  2. Run them on multisite:
    npm run test:php -- --filter Tests_Admin_wpDebugDataPlugins -c tests/phpunit/multisite.xml
  3. Run them in random order:
    npm run test:php -- --filter Tests_Admin_wpDebugDataPlugins --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/wpDebugDataPlugins.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 found no blocking issues in this test-only change; tests were not executed.

No open issues 🎉

What changed in this PR

Adds unit coverage for the plugin sections of Site Health Info and copied debug data, without changing production code.

Changes:

  • Tests plugin metadata formatting, active/inactive grouping, and available updates.
  • Covers auto-update settings, filters, and filter arguments.
  • Adds fixture setup and cleanup for plugin files, caches, and settings.
File Description
tests/​phpunit/​tests/​admin/​wpDebugDataPlugins.php Adds tests for must-use and regular plugin debug data.

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 unit-tests audit found no landing blockers. The affected classes passed individually and together across three randomized seeds on single-site and multisite, with no failures or skips. PHPCS passed.

Optional follow-up: also assert the literal copied debug text version: 1.0, author: Jane, Custom in the filtered auto-update-string case, so the custom status is protected in both outputs.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Oct 20, 2026
Test the plugin sections produced by `WP_Debug_Data`, including must-use plugins, active and inactive plugins, available updates, auto-update settings, and filtered debug strings.

Developed in: #14583

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64665 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 20, 2026
Test the plugin sections produced by `WP_Debug_Data`, including must-use plugins, active and inactive plugins, available updates, auto-update settings, and filtered debug strings.

Developed in: WordPress/wordpress-develop#14583

Props huzaifaalmesbah.
See #65819.

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


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