Opened 6 days ago
Last modified 6 days ago
#66553 new enhancement
Tests: Add unit tests for plugins_api()
| Reported by: | hmbashar | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Plugins | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
plugins_api() has no direct unit tests, and 17 of its lines are not covered on Codecov. It builds the arguments, asks WordPress.org for the plugin information and handles the errors.
This ticket adds tests for the default arguments, the plugins_api_args, plugins_api and plugins_api_result filters, the request to WordPress.org, a response that is not JSON, an error in the response, and the request that is made again without SSL when the secure request fails.
Change History (1)
This ticket was mentioned in PR #15714 on WordPress/wordpress-develop by @hmbashar.
6 days ago
#1
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Summary
Adds tests for
plugins_api(), which had no direct tests (17 lines were not covered on Codecov).plugins_api_args,plugins_apiandplugins_api_resultfilters: a result ofplugins_apiis returned without a request and is marked as external, except for an error.api.wordpress.org/plugins/info/1.2/, its action, arguments, timeout and user agent, and the response as an object.Testing
Mutation check: 24 changes to
plugins_api()(defaults, conditions, timeout, user agent, SSL retry, error codes and data, theexternalflag and the filters) were each caught by a test.The branch that makes one request when SSL is not supported is not tested, because
wp_http_supports()depends on the transports of the server. The two SSL tests are skipped when SSL is not supported.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.