From 32f8a1e4eb73d864ea15f34b2d2e5a63fd49bee2 Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Fri, 18 Sep 2026 12:47:49 +0300 Subject: [PATCH] Build/Test Tools: Mock the rejected requests in the `wp_get_http_headers()` tests. Two tests call `wp_get_http_headers()` with a URL that `wp_http_validate_url()` rejects. No request left the machine. But `pre_http_request` runs before that check, and the mock in this class passed those URLs on, so the guard against ungrouped external requests fails both tests. The mock now returns the `WP_Error` that `WP_Http::request()` returns for an invalid URL. The tests leave the `external-http` group. --- tests/phpunit/tests/http/wpGetHttpHeaders.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/phpunit/tests/http/wpGetHttpHeaders.php b/tests/phpunit/tests/http/wpGetHttpHeaders.php index 855497674b510..450b582ec6360 100644 --- a/tests/phpunit/tests/http/wpGetHttpHeaders.php +++ b/tests/phpunit/tests/http/wpGetHttpHeaders.php @@ -26,8 +26,6 @@ public function test_wp_get_http_headers_valid_url() { /** * Test with an invalid URL - * - * @group external-http */ public function test_wp_get_http_headers_invalid_url() { $result = wp_get_http_headers( 'not_an_url' ); @@ -36,8 +34,6 @@ public function test_wp_get_http_headers_invalid_url() { /** * Test to see if the deprecated argument is working - * - * @group external-http */ public function test_wp_get_http_headers_deprecated_argument() { $this->setExpectedDeprecated( 'wp_get_http_headers' ); @@ -58,6 +54,6 @@ public function mock_http_request( $response, $parsed_args, $url ) { return array( 'headers' => true ); } - return $response; + return new WP_Error( 'http_request_failed', 'A valid URL was not provided.' ); } }