Opened 6 days ago
Last modified 6 days ago
#66552 new enhancement
Tests: Add unit test coverage for WP_Plugins_List_Table
| Reported by: | huzaifaalmesbah | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Plugins | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
src/wp-admin/includes/class-wp-plugins-list-table.php contains 822 lines across 22 methods responsible for managing and displaying installed plugins in the WordPress admin (wp-admin/plugins.php).
According to local PHPUnit code coverage analysis, WP_Plugins_List_Table currently has 0.00% unit test coverage (0/22 methods and 0/822 lines covered). There are no dedicated test cases exercising its configuration, capability checks, search callbacks, or row display logic.
Proposed Changes
Add a dedicated PHPUnit test suite for WP_Plugins_List_Table in tests/phpunit/tests/admin/wpPluginsListTable.php to cover:
- Table initialization and configuration:
ajax_user_can(): verify capability checks foractivate_plugins.get_table_classes(): assert the expected table class names (plugins,wp-list-table,widefat).get_columns()andget_sortable_columns(): assert default columns and sortable definitions.get_primary_column_name(): verify primary column designation (name).
- Search and filtering:
_search_callback(): assert filtering against plugin name, description, author, and tags.
- Bulk actions and tablenav:
bulk_actions(): verify bulk action options for single-site and multisite contexts.extra_tablenav()andcurrent_action(): verify action resolution and markup output.
- Row rendering:
single_row()anddisplay_rows(): assert output formatting for active, inactive, and auto-update-enabled plugins.
Change History (1)
This ticket was mentioned in PR #15715 on WordPress/wordpress-develop by @hmbashar.
6 days ago
#1
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Summary
Adds tests for the parts of
WP_Plugins_List_Tablethat the existing tests do not cover, intests/phpunit/tests/admin/wpPluginsListTable.php. The class already has tests for the bulk actions, the action links, the dependency rows, the search box andprepare_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, theplugins_list_status_textfilter, escaping, and statuses without plugins.bulk_actions(),extra_tablenav()(the Clear List button and the Must-Use and Drop-ins notes) andcurrent_action().display_rows(), including Must-Use plugins and drop-ins on a site of a network.single_row(): the setting for automatic updates, theplugin_auto_update_setting_htmlfilter, custom columns, drop-in rows and the message for a plugin that is not compatible.Testing
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_capfilter, becauseupdate_phpmaps toupdate_core.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.