Skip to content

Tests: Add unit tests for the notices and the footer of install_plugin_information() - #15751

Open
hmbashar wants to merge 2 commits into
WordPress:trunkfrom
hmbashar:66566-install-plugin-information-footer-tests
Open

hmbashar wants to merge 2 commits into
WordPress:trunkfrom
hmbashar:66566-install-plugin-information-footer-tests

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Part 3 of the tests for install_plugin_information() (ticket #66566): the notices about the compatibility and the footer with the button. The data and the sections, and the sidebar, are in other pull requests.

  • No notice is output for a plugin that is compatible.
  • A plugin that needs a newer version of PHP gets an error notice, with the link to learn about updating PHP only for a user who can.
  • A plugin that has not been tested with the version of WordPress gets a warning, and that warning is output instead of the notice about a newer version of WordPress.
  • A plugin that needs a newer version of WordPress gets an error notice, with the link to update WordPress only for a user who can.
  • The footer, the button to install the plugin (on the right and with the identifier that the screen uses), no button without a package or for a user who cannot install or update plugins, the button to activate that does not get the identifier of the button to install, and the button to update for a user who can only update plugins.
  • The templates of the notices of the updates, and the dialog for the credentials of the filesystem when it needs them.

Testing

vendor/bin/phpunit --filter 'Admin_Includes_Plugin_Install_InstallPluginInformationFooter_Test::'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Admin_Includes_Plugin_Install_InstallPluginInformationFooter_Test::'
vendor/bin/phpcs tests/phpunit/tests/admin/includes/plugin-install/InstallPluginInformationFooter_Test.php

Mutation check: 19 changes to this part of the function (the compatibility checks, the capabilities, the types and the links of the notices, the footer, the conditions and the changes of the button, and the dialog) were each caught by a test, on single-site and multisite. Two changes are equivalent: the check of the capabilities in front of the button (a user who cannot do either gets an empty button anyway), and wp_kses_post() of the button (it does not change this markup).

The test for a user who can only update plugins is not run on multisite, where only a super admin can update plugins. The screen sends headers, which PHP refuses because the tests have output already, so the tests ignore that warning only.

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

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.

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 test handler’s E_WARNING-only mask lets other errors bypass PHPUnit and be captured as output without failing the tests.

1 open issue
What changed in this PR

Adds unit tests for the compatibility notices and footer of install_plugin_information(), extending coverage for ticket #66566 without changing production code.

Changes:

  • Covers PHP and WordPress compatibility notices, permission-dependent links, and notice precedence.
  • Tests install, activate, and update buttons, plus cases where no button should appear.
  • Checks update notice templates and the filesystem credentials dialog.
File Description
tests/​phpunit/​tests/​admin/​includes/​plugin-install/​InstallPluginInformationFooter_Test.php Adds rendering helpers and tests for compatibility notices and footer behavior.

Review effort: Balanced

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

@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 covering the compatibility notices and footer actions, @hmbashar! Testing the precedence between WordPress and PHP compatibility notices, as well as the install/update button permission states, is very thorough.

All 97 CI checks pass.

A small suggestion on the error handler in render() (around line 159):
Passing E_ALL instead of E_WARNING to set_error_handler() will allow the wrapper to catch notices and deprecations and delegate them to $previous_handler, ensuring unexpected diagnostics don't slip into output silently.

Nicely done!

AI Review: Gemini 3.8 Flash

@hmbashar

hmbashar commented Nov 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review, @huzaifaalmesbah. Changed the error handler mask from E_WARNING to E_ALL in 3bf506d.

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