Skip to content

Tests: Add unit tests for WP_Plugin_Install_List_Table::display_rows() - #15724

Open
hmbashar wants to merge 2 commits into
WordPress:trunkfrom
hmbashar:66554-plugin-install-list-table-rows-tests
Open

hmbashar wants to merge 2 commits into
WordPress:trunkfrom
hmbashar:66554-plugin-install-list-table-rows-tests

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Part 3 of the tests for WP_Plugin_Install_List_Table (ticket #66554): display_rows(), the largest method of the class (162 lines were not covered). The other parts are separate pull requests, one for each area. The notice about the dependencies of a plugin already has its own tests.

  • The card of a plugin (class, name, description, author, link and label of the details) for an array and for an object, and one card for each plugin.
  • The markup that is not allowed is removed from the title, description and author.
  • The plugin_install_description filter, and a plugin without an author.
  • The groups: the heading of each group once, the name of a group that is not listed, no group without one, and the groups that are closed.
  • The icon: the SVG, the 2x icon, the 1x icon and the default icon.
  • The plugin_install_action_links filter, and no list of actions when the filter removes them.
  • The rating and the number of ratings, the time since the last update, and the active installations (none, a few, thousands, millions).
  • The compatibility with the version of WordPress (compatible, not tested, incompatible) and the notice for a plugin that is not compatible, by what the user can update (update_core and update_php, with the notice for WordPress, for PHP, and for both).

Testing

vendor/bin/phpunit --filter 'Tests_Admin_wpPluginInstallListTableDisplayRows::'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Admin_wpPluginInstallListTableDisplayRows::'
vendor/bin/phpcs tests/phpunit/tests/admin/wpPluginInstallListTableDisplayRows.php

Mutation check: 27 changes to display_rows() (the object cast, the groups, the sanitizing, the filters, the icons, the notice and its capabilities, the active installations and the compatibility) were each caught by a test.

$wp_version is set to 7.0 in the tests, so the compatibility does not depend on the version of the checkout. The notice for a user who can update WordPress but not PHP (and the reverse) uses a map_meta_cap filter, because update_php maps to update_core.

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

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.

@github-actions

github-actions Bot commented Nov 6, 2026 •

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.

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

Props hmbashar, huzaifaalmesbah.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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.

🟡 Changes recommended

The test matches the plugin name anywhere in the output, so link attributes can satisfy it even when the visible card heading is missing.

1 open issue
What changed in this PR

Adds unit tests for WP_Plugin_Install_List_Table::display_rows() as part of ticket #66554, expanding coverage of plugin cards in the admin installer without changing production code.

Changes:

  • Covers card content, sanitization, filters, grouping, and icon selection.
  • Tests ratings, update age, installation counts, and compatibility indicators.
  • Exercises incompatibility notices across update capabilities, using a fixed WordPress version for stable expectations.
File Description
tests/​phpunit/​tests/​admin/​wpPluginInstallListTableDisplayRows.php Adds fixtures, data providers, and tests for plugin card rendering and compatibility notices.

Review effort: Balanced

@huzaifaalmesbah huzaifaalmesbah 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.

Thanks for working on this, @hmbashar! Extensive test coverage for WP_Plugin_Install_List_Table::display_rows() including ratings, author links, and compatibility badges.

A couple of points to consider:

  1. Heading assertion (line ~136): Asserting the plugin title within the card heading (<h3> or specific title container) rather than anywhere in $output prevents false passes from aria-label or data-title attributes.
  2. Class name capitalization: In tests/phpunit/tests/admin/wpPluginInstallListTableDisplayRows.php, changing Tests_Admin_wpPluginInstallListTableDisplayRows to Tests_Admin_WpPluginInstallListTableDisplayRows fixes a minor PHPCS naming notice.

All 96 CI checks pass cleanly!

AI Review: Gemini 3.8 Flash

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