From fc679967c8831d0427502111fd6240df80f02e23 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Sat, 7 Nov 2026 05:29:33 +0000 Subject: [PATCH 1/2] Tests: Move streams transport suite off live external HTTP. Follows the cURL change from #63914: keep shared fixture coverage offline and leave only test_ssl() as intentional live TLS smoke. --- tests/phpunit/tests/http/streams.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/http/streams.php b/tests/phpunit/tests/http/streams.php index 9ae1b305122f3..8e771f8dea02c 100644 --- a/tests/phpunit/tests/http/streams.php +++ b/tests/phpunit/tests/http/streams.php @@ -4,7 +4,8 @@ /** * @group http - * @group external-http + * + * @ticket 63914 */ class Tests_HTTP_streams extends WP_HTTP_UnitTestCase { public $transport = 'streams'; From 046322353c6e908abad8ca27d15e90ad7e382a6a Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Sat, 7 Nov 2026 17:46:57 +0000 Subject: [PATCH 2/2] Tests: Force Requests transport in HTTP transport suites. Ensure curl and streams suites exercise their intended transport instead of whichever Requests picks by default. --- tests/phpunit/tests/http/base.php | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index ba78b8b2ed15d..a279a8386024a 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -299,13 +299,10 @@ public function set_up() { $this->markTestSkipped( sprintf( 'The transport %s is not supported on this system.', $this->transport ) ); } - // Disable all transports aside from this one. - foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) { - remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all... - if ( $t !== $this->transport ) { - add_filter( "use_{$t}_transport", '__return_false' ); // ...and add it back if need be. - } - } + // WP_Http::request() uses Requests directly; force the transport this + // subclass is meant to cover. The empty() check leaves tests that set + // their own transport (e.g. the parent-domain cookie mock) alone. + add_action( 'requests-requests.before_request', array( $this, 'force_requests_transport' ), 10, 5 ); if ( self::$file_stream_fixture_url ) { $this->file_stream_url = self::$file_stream_fixture_url; @@ -975,6 +972,27 @@ public function test_parent_domain_cookie_is_sent_on_redirect() { $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } + /** + * Forces Requests to use the transport this subclass is covering. + * + * The legacy use_{$t}_transport filters are only consulted by + * WP_Http_Curl::test() / WP_Http_Streams::test(). Requests picks its own + * transport unless options['transport'] is set. + * + * @param string $url Request URL. + * @param array $headers Request headers. + * @param string|array $data Request data. + * @param string $type HTTP method. + * @param array $options Request options (passed by reference). + */ + 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; + } + } + /** * Injects the parent-domain cookie test transport into Requests options. *