Skip to content

Commit

Permalink
test: do not perform external requests in WPCOM_VIP_Utils_Vip_Is_Jetp…
Browse files Browse the repository at this point in the history
…ack_Request_Test (#4792)
  • Loading branch information
sjinks authored Sep 12, 2023
1 parent 81e6b2b commit 94d8286
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
<?php

use Automattic\VIP\Utils\Jetpack_IP_Manager;

class WPCOM_VIP_Utils_Vip_Is_Jetpack_Request_Test extends WP_UnitTestCase {
public function setUp(): void {
parent::setUp();

add_filter( 'pre_http_request', function ( $response, $args, $url ) {
if ( Jetpack_IP_Manager::ENDPOINT === $url ) {
$response = [
'headers' => [],
'body' => '["122.248.245.244\/32","54.217.201.243\/32","54.232.116.4\/32","192.0.80.0\/20","192.0.96.0\/20","192.0.112.0\/20","195.234.108.0\/22"]',
'response' => [
'code' => 200,
'message' => 'OK',
],
'cookies' => [],
];
}

return $response;
}, 10, 3 );
}

public function test__vip_is_jetpack_request__shortcut() {
//phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
Expand Down

0 comments on commit 94d8286

Please sign in to comment.