Skip to content

Tests: Add unit tests for Plugin_Upgrader::bulk_upgrade() - #15743

Open
hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:66563-plugin-upgrader-bulk-upgrade-tests
Open

hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:66563-plugin-upgrader-bulk-upgrade-tests

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Adds tests for Plugin_Upgrader::bulk_upgrade(). The callbacks, check_package(), plugin_info(), install() and upgrade() already have tests, so this was the part of the class that was left.

  • The skin is told about the header, the bulk header, the bulk footer and the footer, and the update does not start without access to the filesystem (the skin gets the header and the footer, and false is returned).
  • A plugin without an update is reported as up to date (the result, the message and the data of the plugin are given to the skin).
  • A plugin that needs a newer version of WordPress or PHP is not updated and gets a WP_Error (incompatible_wp_required_version, incompatible_php_required_version) that the skin is told about.
  • The update runs with the package of the update and the options of a bulk update (the plugins directory, the old plugin removed, is_multi, the plugin and its temporary backup).
  • The package check and the deletion of the old plugin are hooked only while the plugins are updated, and the update stops when a plugin returns false, but continues after a plugin that failed with an error.
  • The counts of the plugins, the strings, the upgrader_process_complete action with its arguments, the update information that is cleaned (or kept when it is not asked to clean it), and the skin knowing that the plugin is active.
  • The emails about failures are forgotten only for the plugins that are up to date, and the others are kept.

Testing

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

Mutation check: 36 changes to bulk_upgrade() (the flags, the strings, the filesystem, the skin calls, the compatibility checks, the options of the update, the hooks and their removal, the stop, the cache, the action, the footers and the emails) were each caught by a test, on single-site and multisite.

The skin of the tests keeps what it is told. The messages about the maintenance mode, which only a network gives, are left out when the tests compare what the skin was told. A plugin that is active and has an update is not updated in the tests, so no .maintenance file is written.

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

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.

@hmbashar
hmbashar marked this pull request as ready for review November 6, 2026 16:32
@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.

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.

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.

1 participant