Build/Test Tools: Mock the external HTTP request in the get_theme_feature_list() test. - #13605
Draft
adimoldovan wants to merge 3 commits into
Draft
adimoldovan wants to merge 3 commits into
adimoldovan wants to merge 3 commits into
Conversation
…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.
`assertSame()` on the exact output already covers the non-empty multidimensional array check. The docblock now says that the response is mocked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: core.trac.wordpress.org/ticket/63914
Mock the Themes API request in
Tests_Admin_IncludesTheme::test_get_theme_featured_list_api()withpre_http_requestand move the test out of theexternal-httpgroup.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
npm run env:start && npm run env:install.npm run test:php -- --group external-http. Expect 84 tests and no failures.npm run test:php -- --exclude-group external-http tests/phpunit/tests/admin/includesTheme.php. Expect 6 tests and no failures.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.