Skip to content

Build/Test Tools: Mock the external HTTP request in the get_theme_feature_list() test. - #13605

Draft
adimoldovan wants to merge 3 commits into
WordPress:trunkfrom
adimoldovan:63914-admin-includes-theme
Draft

adimoldovan wants to merge 3 commits into
WordPress:trunkfrom
adimoldovan:63914-admin-includes-theme

Conversation

@adimoldovan

Copy link
Copy Markdown

Trac ticket: core.trac.wordpress.org/ticket/63914

Mock the Themes API request in Tests_Admin_IncludesTheme::test_get_theme_featured_list_api() with pre_http_request and move the test out of the external-http group.

The test asserted only a non-empty multidimensional array. get_theme_feature_list() returns the hard-coded list when the request fails, so a rate-limited response passed too. The test now asserts the exact translated output, with one feature slug that core does not know, so the mock loses no coverage.

Testing Instructions

  1. Start the environment: npm run env:start && npm run env:install.
  2. Run npm run test:php -- --group external-http. Expect 84 tests and no failures.
  3. Run npm run test:php -- --exclude-group external-http tests/phpunit/tests/admin/includesTheme.php. Expect 6 tests and no failures.
  4. Check the coding standards: composer lint tests/phpunit/tests/admin/includesTheme.php.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5.1
Used for: Verifying the mock against the live code path, running the test suites.


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.

…ature_list()` test.

Answer the Themes API request in `test_get_theme_featured_list_api()` with a fixed response through `pre_http_request`, and move the test out of the `external-http` group.

The test asserted only a non-empty multidimensional array. `get_theme_feature_list()` returns the hard-coded list when the request fails, so a rate-limited response passed too. The test now asserts the exact translated output, with one feature slug that core does not know.
@adimoldovan adimoldovan self-assigned this Sep 18, 2026
`assertSame()` on the exact output already covers the non-empty multidimensional array check. The docblock now says that the response is mocked.
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