Skip to content

Commit 1be36a0

Browse files
committed
Build/Test Tools: Mock the Site Health controller HTTP request.
Mock the WordPress.org response in the Site Health REST controller test. Remove its external-http annotation so the administrator route test runs in the default suite without a network request. Developed in: #13606 Props adrianmoldovanwp, johnbillion. See #63914. git-svn-id: https://develop.svn.wordpress.org/trunk@63877 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3b89671 commit 1be36a0

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎tests/phpunit/tests/rest-api/rest-site-health-controller.php‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,24 @@ static function () {
9292
$this->assertErrorResponse( 'rest_forbidden', $response, 403 );
9393
}
9494

95-
/**
96-
* @group external-http
97-
*/
9895
public function test() {
9996
wp_set_current_user( self::$admin );
97+
add_filter(
98+
'pre_http_request',
99+
static function () {
100+
return array(
101+
'headers' => array(),
102+
'body' => '',
103+
'response' => array(
104+
'code' => 200,
105+
'message' => 'OK',
106+
),
107+
'cookies' => array(),
108+
'filename' => null,
109+
);
110+
}
111+
);
112+
100113
$response = rest_do_request( '/wp-site-health/v1/tests/dotorg-communication' );
101114
$this->assertSame( 'dotorg_communication', $response->get_data()['test'] );
102115
}

0 commit comments

Comments
 (0)