Build/Test Tools: Mock the external HTTP request in the spam site embed test. - #13607
Draft
adimoldovan wants to merge 1 commit into
Draft
adimoldovan wants to merge 1 commit into
adimoldovan wants to merge 1 commit into
Conversation
…embed test. `test_content_from_spam_blog_is_not_available()` embeds a URL from a spam site. `get_oembed_response_data_for_url()` refuses the embed. `WP_oEmbed::discover()` then requests the URL from example.org. Mock that request with `pre_http_request`. Move the test out of the `external-http` group.
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 oEmbed discovery request in
Tests_Multisite_UpdateBlogStatus::test_content_from_spam_blog_is_not_available()withpre_http_requestand move the test out of theexternal-httpgroup.The test embeds a URL from a spam site.
get_oembed_response_data_for_url()refuses the embed before any request.WP_oEmbed::discover()then requests the URL from example.org, which is not a WordPress site and has no oEmbed link. The mock also has no oEmbed link, so it loses no coverage.Testing Instructions
npm run env:start && npm run env:install.npm run test:php -- --group external-http. Expect 85 tests and no failures.npm run test:php -- -c tests/phpunit/multisite.xml --exclude-group external-http tests/phpunit/tests/multisite/updateBlogStatus.php. Expect 12 tests and no failures.get_oembed_response_data_for_url()insrc/wp-includes/embed.php, replace the condition below the commentDo not allow embeds for deleted/archived/spam sites.withfalse. Run step 3 again. Expecttest_content_from_spam_blog_is_not_availableto fail. Revert the change.composer lint tests/phpunit/tests/multisite/updateBlogStatus.php.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5.1, Claude Opus 5
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.