Skip to content

Build/Test Tools: Mock the external HTTP request in the spam site embed test. - #13607

Draft
adimoldovan wants to merge 1 commit into
WordPress:trunkfrom
adimoldovan:63914-multisite-update-blog-status
Draft

adimoldovan wants to merge 1 commit into
WordPress:trunkfrom
adimoldovan:63914-multisite-update-blog-status

Conversation

@adimoldovan

Copy link
Copy Markdown

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() with pre_http_request and move the test out of the external-http group.

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

  1. Start the environment: npm run env:start && npm run env:install.
  2. Run npm run test:php -- --group external-http. Expect 85 tests and no failures.
  3. Run 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.
  4. In get_oembed_response_data_for_url() in src/wp-includes/embed.php, replace the condition below the comment Do not allow embeds for deleted/archived/spam sites. with false. Run step 3 again. Expect test_content_from_spam_blog_is_not_available to fail. Revert the change.
  5. Check the coding standards: 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.

…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.
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