Repository navigation
Tests: Move streams transport suite off live external HTTP - #15787
shail-mehta wants to merge 2 commits into
Conversation
Follows the cURL change from #63914: keep shared fixture coverage offline and leave only test_ssl() as intentional live TLS smoke.
There was a problem hiding this comment.
🟢 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-httpannotation. - Adds
@ticket 63914to 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
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
lancewillett
left a comment
There was a problem hiding this comment.
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_streamsruns 26 tests, 61 assertions, all passing. - With
Fsockopen::request()set to throw,Tests_HTTP_streamsstill passes all 26. - With
Curl::request()set to throw,Tests_HTTP_streamserrors 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_streamsandTests_HTTP_curleach pass 26 tests, 61 assertions.- Breaking
Fsockopen::request()fails only the streams suite (24 errors). BreakingCurl::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.
|
Thanks! Addressed in 0463223 |
lancewillett
left a comment
There was a problem hiding this comment.
Thanks, this works. Re-checked at 0463223, offline (no DNS), single site and multisite:
Tests_HTTP_streamsandTests_HTTP_curleach pass 26 tests and 61 assertions.- Breaking
Fsockopen::request()fails only the streams suite (24 errors). BreakingCurl::request()fails only the cURL suite. So each class now tests its own transport. --group httpgoes from 262 to 288 tests, with the same 3 offline DNS failures as trunk (Tests_HTTP_HTTPURL validation andTests_HTTP_IncludeOldRequestsClass).- PHPCS is clean, CI is green, and it applies cleanly to trunk.
Ready to land.
AI review · claude-opus-5-5
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
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
|
PR #15787 landed in https://core.trac.wordpress.org/changeset/65333 |
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
Trac ticket: #63914
What
Moves
Tests_HTTP_streamsout of theexternal-httpgroup. Shared coverage inWP_HTTP_UnitTestCasealready runs against the local HTTP fixture (landed with the cURL work in r65320 / #15488). Onlytest_ssl()stays inexternal-httpas intentional live TLS smoke.Why
After #15488,
streams.phpwas the remaining transport class still tagged@group external-httpat class level. Redirect, stream, cookie, and header checks do not need the public network.How
@group external-httpfromtests/phpunit/tests/http/streams.php@ticket 63914to matchcurl.phptest_ssl()on method-level@group external-httpinbase.phpTesting instructions
npm run env:start && npm run env:installnpm run test:php -- --filter Tests_HTTP_streams --exclude-group external-httpnpm run test:php -- --filter 'Tests_HTTP_streams::test_ssl' --group external-httpexternal-httpUse of AI Tools