Skip to content

Tests: Move streams transport suite off live external HTTP - #15787

Closed
shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:tests/63914-streams-external-http
Closed

shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:tests/63914-streams-external-http

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #63914

What

Moves Tests_HTTP_streams out of the external-http group. Shared coverage in WP_HTTP_UnitTestCase already runs against the local HTTP fixture (landed with the cURL work in r65320 / #15488). Only test_ssl() stays in external-http as intentional live TLS smoke.

Why

After #15488, streams.php was the remaining transport class still tagged @group external-http at class level. Redirect, stream, cookie, and header checks do not need the public network.

How

  • Remove class-level @group external-http from tests/phpunit/tests/http/streams.php
  • Add @ticket 63914 to match curl.php
  • Leave test_ssl() on method-level @group external-http in base.php

Testing instructions

  1. Start the local environment: npm run env:start && npm run env:install
  2. Run: npm run test:php -- --filter Tests_HTTP_streams --exclude-group external-http
  3. Expect the streams suite to pass with no live HTTP (same offline failures as trunk if any DNS-related skips elsewhere)
  4. Run: npm run test:php -- --filter 'Tests_HTTP_streams::test_ssl' --group external-http
  5. Expect the live SSL smoke test to still run in external-http

Use of AI Tools

  • Cursor

Follows the cURL change from #63914: keep shared fixture coverage offline and leave only test_ssl() as intentional live TLS smoke.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the streams test annotation changes.

No open issues 🎉

What changed in this PR

Moves the streams transport test suite out of the external-http group, aligning it with the earlier cURL migration to the shared local HTTP fixture. The existing method-level grouping keeps test_ssl() as live TLS smoke coverage.

Changes:

  • Removes the class-level @group external-http annotation.
  • Adds @ticket 63914 to link the suite to the tracking ticket.
File Description
tests/​phpunit/​tests/​http/​streams.php Updates test annotations so local-fixture coverage runs outside external-http.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 7, 2026 15:03
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. One blocker: as written, Tests_HTTP_streams never uses the streams transport, so this would run the cURL tests a second time.

The use_{$t}_transport filters in WP_HTTP_UnitTestCase::set_up() are only read by WP_Http_Curl::test() and WP_Http_Streams::test(). WP_Http::request() calls WpOrg\Requests\Requests::request() directly, and Requests picks its own transport (cURL when available).

What I checked at fc67996, offline (no DNS), single site and multisite:

  • With the PR, Tests_HTTP_streams runs 26 tests, 61 assertions, all passing.
  • With Fsockopen::request() set to throw, Tests_HTTP_streams still passes all 26.
  • With Curl::request() set to throw, Tests_HTTP_streams errors in 24 of 26. So the streams suite is exercising cURL.

A fix that worked for me: force the Requests transport per class in base.php.

public function force_requests_transport( &$url, &$headers, &$data, &$type, &$options ) {
	if ( empty( $options['transport'] ) ) {
		$options['transport'] = 'curl' === $this->transport
			? \WpOrg\Requests\Transport\Curl::class
			: \WpOrg\Requests\Transport\Fsockopen::class;
	}
}

Register it in set_up() with add_action( 'requests-requests.before_request', array( $this, 'force_requests_transport' ), 10, 5 );. The empty() check leaves the parent-domain cookie test's own transport alone.

With that change, offline, single site and multisite:

  • Tests_HTTP_streams and Tests_HTTP_curl each pass 26 tests, 61 assertions.
  • Breaking Fsockopen::request() fails only the streams suite (24 errors). Breaking Curl::request() fails only the cURL suite.
  • PHPCS is clean.

With that in base.php, removing the class-level @group external-http from streams.php gives real offline coverage of the streams transport. The old filter loop can probably go too, but that's optional.

AI review · claude-opus-5-5

Ensure curl and streams suites exercise their intended transport instead of whichever Requests picks by default.
@shail-mehta

Copy link
Copy Markdown
Member Author

Thanks! Addressed in 0463223

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works. Re-checked at 0463223, offline (no DNS), single site and multisite:

  • Tests_HTTP_streams and Tests_HTTP_curl each pass 26 tests and 61 assertions.
  • Breaking Fsockopen::request() fails only the streams suite (24 errors). Breaking Curl::request() fails only the cURL suite. So each class now tests its own transport.
  • --group http goes from 262 to 288 tests, with the same 3 offline DNS failures as trunk (Tests_HTTP_HTTP URL validation and Tests_HTTP_IncludeOldRequestsClass).
  • PHPCS is clean, CI is green, and it applies cleanly to trunk.

Ready to land.

AI review · claude-opus-5-5

wporg-sync pushed a commit that referenced this pull request Nov 7, 2026
The HTTP transport tests chose a transport with the `use_{$transport}_transport` filters, which only `WP_Http_Curl::test()` and `WP_Http_Streams::test()` read. `WP_Http::request()` passes requests to Requests, which picked cURL, so `Tests_HTTP_streams` was running on cURL. Set the Requests transport for each test class instead, and move the streams tests out of the external-http group.

Follow-up to [65320].

Developed in: #15787

Props shailu25.
See #63914.


git-svn-id: https://develop.svn.wordpress.org/trunk@65333 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 7, 2026
The HTTP transport tests chose a transport with the `use_{$transport}_transport` filters, which only `WP_Http_Curl::test()` and `WP_Http_Streams::test()` read. `WP_Http::request()` passes requests to Requests, which picked cURL, so `Tests_HTTP_streams` was running on cURL. Set the Requests transport for each test class instead, and move the streams tests out of the external-http group.

Follow-up to [65320].

Developed in: WordPress/wordpress-develop#15787

Props shailu25.
See #63914.

Built from https://develop.svn.wordpress.org/trunk@65333


git-svn-id: http://core.svn.wordpress.org/trunk@64473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@lancewillett

Copy link
Copy Markdown
Member

arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
The HTTP transport tests chose a transport with the `use_{$transport}_transport` filters, which only `WP_Http_Curl::test()` and `WP_Http_Streams::test()` read. `WP_Http::request()` passes requests to Requests, which picked cURL, so `Tests_HTTP_streams` was running on cURL. Set the Requests transport for each test class instead, and move the streams tests out of the external-http group.

Follow-up to [65320].

Developed in: WordPress#15787

Props shailu25.
See #63914.


git-svn-id: https://develop.svn.wordpress.org/trunk@65333 602fd350-edb4-49c9-b593-d223f7449a82
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.

3 participants