Make WordPress Core

Opened 6 days ago

Last modified 6 days ago

#66551 new enhancement

Tests: Add unit tests for Plugin_Upgrader_Skin

Reported by: hmbashar Owned by:
Priority: normal Milestone: Awaiting Review
Component: Upgrade/Install Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Plugin_Upgrader_Skin has no test coverage. It sets up the skin of the plugin update screen, and after an update it shows the frame that activates an active plugin again, the links to activate the plugin and to the Plugins page, and the update count script.

This ticket adds tests for the constructor (defaults, arguments, active and network active plugins) and for after() (the frame, the links, who gets the link to activate the plugin, the update_plugin_complete_actions filter and the update count).

Change History (1)

This ticket was mentioned in ​PR #15713 on ​WordPress/wordpress-develop by ​@hmbashar.


6 days ago
#1

Summary

Adds tests for Plugin_Upgrader_Skin, which had no coverage (0% on Codecov).

  • The constructor uses the defaults and the arguments, and detects an active plugin and a network active plugin.
  • after() activates an active plugin again in a frame, but not an inactive plugin, a failed update or an update without an installed plugin.
  • after() links to activate the plugin and to the Plugins page, and leaves out the link to activate it after a failure or for a user who cannot activate plugins.
  • The update_plugin_complete_actions filter receives the links and the plugin file, and no feedback is given when the links are removed.
  • The update count is decremented after a successful update only.

Testing

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

Mutation check: 18 changes to class-plugin-upgrader-skin.php (the conditions of the frame and of the links, the filter, the separator, the nonce, the update count) were each caught by a test. The change to the network active check is caught by the multisite run only.

The skin collects its feedback in the test, because show_message() ends all output buffers.

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.

Note: See TracTickets for help on using tickets.