Skip to content

Tests: Add unit tests for the views and the display of WP_Plugin_Install_List_Table - #15723

Closed
hmbashar wants to merge 4 commits into
WordPress:trunkfrom
hmbashar:66554-plugin-install-list-table-views-tests
Closed

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

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Part 2 of the tests for WP_Plugin_Install_List_Table (ticket #66554): the configuration, the views and the display of the table. The other parts are separate pull requests, one for each area. display_tablenav() and no_items() already have tests.

  • ajax_user_can() needs the install_plugins capability (a super admin on multisite).
  • get_table_classes() returns widefat and plugin-install, and get_columns() returns no columns.
  • get_installed_plugin_slugs() lists the slugs of the plugins with and without an update, and ignores the plugins without a slug.
  • get_views() links each tab, marks the current one and leaves out the upload tab.
  • views() outputs the introduction with the link to the plugin directory, the tabs, the views_plugin-install filter, an empty list of tabs, and the search form (but not for the favorites).
  • display() outputs the navigation above and below the list, the classes of the table, the list and the message for an empty list, and no navigation for the featured plugins.

Testing

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

Mutation check: 16 changes to ajax_user_can(), get_table_classes(), get_columns(), get_installed_plugin_slugs(), get_views(), views() and display() were each caught by these tests.

The ticket describes the table classes as plugin-install only and two columns (name and description). The table adds widefat and has no columns, so the tests use what the class does.

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 tests omit multisite denial for ordinary site administrators and populated-table rendering, allowing capability and plugin-card display regressions to pass.

2 open issues
What changed in this PR

Adds the second set of unit tests for WP_Plugin_Install_List_Table under ticket #66554, covering configuration, views, and display behavior without changing production code.

Changes:

  • Tests installation permissions, table classes, columns, and installed plugin slugs.
  • Checks tab links, filtering, introductory content, and search-form visibility.
  • Verifies navigation placement, featured-tab behavior, and empty-list output.
File Description
tests/​phpunit/​tests/​admin/​wpPluginInstallListTableViews.php Adds configuration, view, and display tests with shared setup and cleanup.

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 PR, @hmbashar! Good coverage for WP_Plugin_Install_List_Table tabs, views, and navigation.

All CI checks are green. Two quick observations to consider:

  1. Multisite capability check (line ~107): In the multisite view test, promoting the user before the assertion means denial for an ordinary site administrator without install_plugins isn'''t tested. An assertion verifying denial before super admin promotion would strengthen this.
  2. Populated table display: Testing display() with mock items populated in $table->items would ensure display_rows_or_placeholder() is exercised.
  3. Class naming: Class name uses lowercase wp (Tests_Admin_wpPluginInstallListTableViews); updating to Wp aligns with PHPCS conventions.

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