Repository navigation
Conversation
…ugin_files(). See #66556.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟡 Changes recommended
The test fixtures cannot detect regressions in name-based sorting or hidden-directory exclusion because name and filename ordering coincide, and the hidden plugin sits beyond the scanning depth.
2 open issues
What changed in this PR
Adds PHPUnit coverage for WordPress plugin metadata, discovery, and file listing without changing production code.
Changes:
- Tests plugin headers, text-domain defaults, deprecated headers, and markup behavior.
- Tests plugin discovery, sorting, folder-specific results, and caching.
- Tests plugin file listings and exclusions, with temporary fixtures and cleanup.
| File | Description |
|---|---|
tests/phpunit/tests/admin/includes/plugin/getPlugins.php |
Adds discovery, caching, sorting, and file-listing tests. |
tests/phpunit/tests/admin/includes/plugin/getPluginData.php |
Adds metadata, header fallback, and markup tests. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for adding coverage for plugin discovery and header parsing, @hmbashar!
All CI checks pass cleanly. Two edge-case improvements to make the tests even more resilient:
- Name sorting test fixture (line ~171): In the sort test, the directory/file names and the plugin header names currently follow the same alphabetical order (
a-plugin-> "A Plugin",b-plugin-> "B Plugin"). If name-sorting regressed to sorting by path/key, the test would still pass. Inverting the names (e.g.z-pluginnamed "Alpha Plugin") would ensure true name-based sorting is verified. - Hidden directory exclusion (line ~114): Placing the hidden directory directly in
WP_PLUGIN_DIRrather than two levels down ensures it tests the hidden-directory filter rather than being excluded byget_plugins()' 1-level depth limit.
Solid work overall!
AI Review: Gemini 3.8 Flash
… by a name that differs from the file. See #66556.

Summary
Adds tests for
get_plugin_data(),get_plugins()andget_plugin_files().get_plugin_data_markup_translateandget_plugin_files()(a single file and a folder) already have tests, so these tests cover the rest.getPluginData.phpNetwork,Requires at least,Requires PHP,Update URIandRequires Plugins.Networkheader is read as a boolean, and the deprecatedSite Wide Onlyheader is read and reported, unlessNetworkis set.getPlugins.phpwp_clean_plugins_cache().get_plugin_files()lists the files of the plugin folder, leaves outCVS,node_modules,vendorandbower_components, uses theplugin_files_exclusionsfilter, and lists a plugin file in the plugins directory alone.Testing
Mutation check: 25 changes to the three functions (the headers, the deprecated header, the text domain, the markup branch, the file and folder checks, the sorting, the cache and the exclusions) were each caught by a test.
The tests write plugins into the plugins directory with a random name, and remove them (hidden files and folders included) after each test.
Trac ticket: https://core.trac.wordpress.org/ticket/66556
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
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.