Skip to content

Commit 8b0573e

Browse files
Tests: Use wp_parse_url() in plugin management REST API endpoint tests.
This resolves a warning in preparation for updating to WPCS 3.4.0: {{{ Silencing errors is strongly discouraged. Use proper error checking instead. }}} Additionally, this brings consistency with a similar fragment in the pattern directory endpoint tests, which already used `wp_parse_url()`. Follow-up to [48242], [51021]. See #64894. git-svn-id: https://develop.svn.wordpress.org/trunk@62795 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 07a2d76 commit 8b0573e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

tests/phpunit/tests/rest-api/rest-block-directory-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private function prevent_requests_to_host( $blocked_host = 'api.wordpress.org' )
273273
add_filter(
274274
'pre_http_request',
275275
static function ( $response, $parsed_args, $url ) use ( $blocked_host ) {
276-
if ( @parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
276+
if ( wp_parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
277277
return new WP_Error( 'plugins_api_failed', "An expected error occurred connecting to $blocked_host because of a unit test", "cURL error 7: Failed to connect to $blocked_host port 80: Connection refused" );
278278

279279
}

tests/phpunit/tests/rest-api/rest-plugins-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ private function prevent_requests_to_host( $blocked_host = 'api.wordpress.org' )
11671167
add_filter(
11681168
'pre_http_request',
11691169
static function ( $response, $parsed_args, $url ) use ( $blocked_host ) {
1170-
if ( @parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
1170+
if ( wp_parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
11711171
return new WP_Error( 'plugins_api_failed', "An expected error occurred connecting to $blocked_host because of a unit test", "cURL error 7: Failed to connect to $blocked_host port 80: Connection refused" );
11721172

11731173
}

0 commit comments

Comments
 (0)