Skip to content

Tests: Add unit tests for WP_Plugins_List_Table - #15715

Closed
hmbashar wants to merge 4 commits into
WordPress:trunkfrom
hmbashar:66552-plugins-list-table-tests
Closed

hmbashar wants to merge 4 commits into
WordPress:trunkfrom
hmbashar:66552-plugins-list-table-tests

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Adds tests for the parts of WP_Plugins_List_Table that the existing tests do not cover, in tests/phpunit/tests/admin/wpPluginsListTable.php. The class already has tests for the bulk actions, the action links, the dependency rows, the search box and prepare_items() in other files, so these tests add the methods listed in the ticket that were still missing.

  • __construct(): the search term is added to the request URI.
  • ajax_user_can(), get_table_classes(), get_primary_column_name().
  • get_columns(): the default columns and the automatic updates column.
  • _search_callback(): the name, description (without markup), author, URL-encoded terms, values that are not strings.
  • get_views(): the label of other statuses, the plugins_list_status_text filter, escaping, and statuses without plugins.
  • bulk_actions(), extra_tablenav() (the Clear List button and the Must-Use and Drop-ins notes) and current_action().
  • display_rows(), including Must-Use plugins and drop-ins on a site of a network.
  • single_row(): the setting for automatic updates, the plugin_auto_update_setting_html filter, custom columns, drop-in rows and the message for a plugin that is not compatible.

Testing

vendor/bin/phpunit --filter 'Tests_Admin_wpPluginsListTable'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Admin_wpPluginsListTable'
vendor/bin/phpcs tests/phpunit/tests/admin/wpPluginsListTable.php

Mutation check: 38 changes to class-wp-plugins-list-table.php (the capability, the search, the views, the table navigation, the drop-in rows, the automatic updates setting and the compatibility message) were each caught by a test. The two that depend on multisite are caught by the multisite run.

Notes: the compatibility message for a user who can update WordPress but not PHP (and the reverse) is tested with a map_meta_cap filter, because update_php maps to update_core.

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

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 retains a redundant nested PHP version guard, leaving duplicate checks to maintain.

1 open issue
What changed in this PR

Expands unit coverage for WP_Plugins_List_Table, complementing existing tests for the WordPress admin plugins screen.

Changes:

  • Adds tests for permissions, columns, search matching, status views, and table actions.
  • Covers row rendering, automatic updates, drop-ins, multisite restrictions, and compatibility messages.
  • Introduces helpers for protected-method access, row rendering, and global-state restoration.
File Description
tests/​phpunit/​tests/​admin/​wpPluginsListTable.php Adds list-table tests, data providers, and supporting helpers.

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 the thorough coverage, @hmbashar! Expanding coverage for WP_Plugins_List_Table across status views, auto-updates, and network actions is a great addition.

All CI checks are green across the matrix.

One small optional cleanup: in set_property_accessible(), there is a duplicate nested if ( PHP_VERSION_ID < 80100 ) check around line 184. You can keep the outer check and call setAccessible() directly.

Nice work on the suite!

AI Review: Gemini 3.8 Flash

@hmbashar hmbashar closed this Nov 12, 2026
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