Build/Test Tools: Mock the external HTTP requests in the block patterns controller tests. - #13556
Closed
adimoldovan wants to merge 2 commits into
Closed
adimoldovan wants to merge 2 commits into
adimoldovan wants to merge 2 commits into
Conversation
…ns controller tests. Answer the pattern directory requests in `test_get_items()` and `test_get_items_migrate_pattern_categories()` with an empty response through `pre_http_request`, and move both tests out of the `external-http` group. The tests assert only on patterns in the test registry. They never checked remote patterns, and a failed request left the assertions unchanged. The mock removes the network and keeps the coverage.
adimoldovan
marked this pull request as ready for review
September 16, 2026 10:34
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
adimoldovan
requested review from
desrosj,
johnbillion,
lancewillett and
lucatume
September 16, 2026 13:15
wporg-sync
pushed a commit
that referenced
this pull request
Sep 16, 2026
…ns controller tests. These tests perform an HTTP request to the pattern directory on wordpress.org as a side effect of sending a request to the `wp/v2/block-patterns/patterns` REST API endpoint. The data from the remote pattern directory is not used in the test assertions. This change replaces those unnecessary HTTP requests with a mock response. Developed in #13556 Props adrianmoldovanwp. See #63914 git-svn-id: https://develop.svn.wordpress.org/trunk@63639 602fd350-edb4-49c9-b593-d223f7449a82
Member
wporg-sync
pushed a commit
to WordPress/WordPress
that referenced
this pull request
Sep 16, 2026
…ns controller tests. These tests perform an HTTP request to the pattern directory on wordpress.org as a side effect of sending a request to the `wp/v2/block-patterns/patterns` REST API endpoint. The data from the remote pattern directory is not used in the test assertions. This change replaces those unnecessary HTTP requests with a mock response. Developed in WordPress/wordpress-develop#13556 Props adrianmoldovanwp. See #63914 Built from https://develop.svn.wordpress.org/trunk@63639 git-svn-id: http://core.svn.wordpress.org/trunk@62814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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 pattern directory requests in
Tests_REST_WpRestBlockPatternsController::test_get_items()andtest_get_items_migrate_pattern_categories()withpre_http_requestand move them out of theexternal-httpgroup. The tests assert only on patterns in the test registry. They never checked remote patterns, and a failed request left the assertions unchanged, 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/rest-api/wpRestBlockPatternsController.php. Expect 12 tests and no failures.add_filter( 'pre_http_request', ... )lines and run step 3 again. Expect two failures that name theapi.wordpress.orgURLs. Restore the lines.composer lint tests/phpunit/tests/rest-api/wpRestBlockPatternsController.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.