Skip to content

Tests: Add unit test coverage for WP_Plugins_List_Table::get_bulk_actions() - #14524

Open
huzaifaalmesbah wants to merge 1 commit into
WordPress:trunkfrom
huzaifaalmesbah:tests/plugins-list-table-bulk-actions
Open

huzaifaalmesbah wants to merge 1 commit into
WordPress:trunkfrom
huzaifaalmesbah:tests/plugins-list-table-bulk-actions

Conversation

@huzaifaalmesbah

Copy link
Copy Markdown
Member

Description

Adds tests for WP_Plugins_List_Table::get_bulk_actions(), which builds the Bulk actions dropdown on the Plugins screen. The method had no tests.

The tests build the list table with the requested plugin_status, enable plugin auto-updates through the plugins_auto_update_enabled filter (they are disabled in the test environment), and restore the globals the table sets. They cover:

  • the actions offered for each status: no Activate for active plugins, no Deactivate for inactive and recently active ones, no Delete for active plugins, and no Enable or Disable Auto-updates when that is already the filter;
  • the action labels on a single site;
  • the auto-update actions being left out when plugin auto-updates are disabled;
  • a user who can activate but not update or delete plugins getting only Activate and Deactivate;
  • on multisite, a site's Plugins screen offering only Activate and Deactivate, and the network admin offering Network Activate, Network Deactivate, Update, Delete and the auto-update actions.

The tests are in a new file so that they do not conflict with open PRs that add tests to wpPluginsListTable.php. Removing or changing each branch of the method makes at least one test fail on single site or multisite.

This is a test-only change; no production code is modified.

Testing Instructions

  1. Run the tests on single site:
    npm run test:php -- --filter Tests_Admin_wpPluginsListTableGetBulkActions
  2. Run them on multisite:
    npm run test:php -- --filter Tests_Admin_wpPluginsListTableGetBulkActions -c tests/phpunit/multisite.xml
  3. Run them in random order:
    npm run test:php -- --filter Tests_Admin_wpPluginsListTableGetBulkActions --order-by=random
  4. Run the plugins group:
    npm run test:php -- --group plugins
  5. Run PHPCS on the test file:
    node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpcs tests/phpunit/tests/admin/wpPluginsListTableGetBulkActions.php

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Brainstorming edge-case scenarios and drafting test boilerplate; test architecture, assertions, and local PHPUnit verification were written and validated by me.

@huzaifaalmesbah
huzaifaalmesbah marked this pull request as ready for review October 20, 2026 05:35
@github-actions

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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props huzaifaalmesbah.

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

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.

2 participants