Skip to content

Tests: Add unit tests for the sidebar of install_plugin_information() - #15749

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

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

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Part 2 of the tests for install_plugin_information() (ticket #66566): the sidebar with the details of the plugin. The data and the sections are in another pull request, and the notices and the button in the footer are in a third one.

  • The details that the plugin has are listed: the version, the author (opens in a new tab), the last update, the version of WordPress and PHP that it needs, and the version that it is compatible with. The ones that it does not have are not listed.
  • The active installations: less than 10, ten, thousands, millions, and nothing when the plugin does not have them.
  • The link to the page of the plugin on WordPress.org (not for an external plugin or a response without a slug), the link to the homepage, and the link to donate (in the list when there are no contributors, and after the contributors when there are).
  • The average rating with its stars and the number of ratings (singular and plural), and nothing without a rating.
  • The counters of the reviews for each number of stars, with the link to the reviews, the label for screen readers and the width of the bar, empty bars when the number of ratings is zero, and nothing without ratings.
  • The contributors, with the name escaped, the username when there is no name, and the avatar of 36 pixels.

Testing

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

Mutation check: 32 changes to this part of the function (each detail and its condition, the active installations, the links, the rating, the counters, the division by zero, the contributors and the donate link) were each caught by a test.

The request to WordPress.org is answered with pre_http_request, because the API marks a result that the plugins_api filter returns as external, which hides the link to the page on WordPress.org. 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.

@hmbashar
hmbashar marked this pull request as ready for review November 6, 2026 18:18
@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 error-handler wrapper routes notices and deprecations to PHP’s default handler instead of PHPUnit’s handler, allowing tests to pass despite unexpected diagnostics.

1 open issue
What changed in this PR

Adds sidebar-focused unit tests for install_plugin_information() as part of ticket #66566, without changing production code.

Changes:

  • Covers plugin details, active installation counts, and conditional links.
  • Tests ratings, review counters, contributors, and donation link placement.
  • Adds rendering helpers that mock API responses and stop the screen before request termination.
File Description
tests/​phpunit/​tests/​admin/​includes/​plugin-install/​InstallPluginInformationDetails_Test.php Adds sidebar tests and supporting fixtures and rendering helpers.

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 patch, @hmbashar! Thorough coverage for the plugin details sidebar, active install counts, contributor avatars, and star rating counters.

The pre_http_request mocking for external WordPress.org requests is very neatly done.

Similar to #15748, in render() (around line 170):
Registering set_error_handler() with E_ALL instead of E_WARNING will ensure that non-warning errors (notices, deprecations) aren't caught by PHP's built-in handler and are properly delegated to $previous_handler while still suppressing the expected headers warning.

Solid test coverage overall!

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 e33a21a.

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