- Timestamp:
- 02/04/2024 10:02:02 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-plugins-controller.php
r56559 r57531 42 42 43 43 /** 44 * JSON decoded response from the WordPress.org plugin API. 45 * 46 * @var stdClass 47 */ 48 private static $plugin_api_decoded_response; 49 50 /** 44 51 * Set up class test fixtures. 45 52 * … … 68 75 grant_super_admin( self::$super_admin ); 69 76 } 77 78 self::$plugin_api_decoded_response = json_decode( file_get_contents( DIR_TESTDATA . '/plugins/link-manager.json' ) ); 70 79 } 71 80 … … 1018 1027 1019 1028 /** 1020 * Sets up the plugin download to come locally instead of downloading it from .org 1029 * Sets up the plugin repository requests to use local data. 1030 * 1031 * Requests to the plugin repository are mocked to avoid external HTTP requests so 1032 * the test suite does not produce false negatives due to network failures. 1033 * 1034 * Both the plugin ZIP file and the plugin API response are mocked. 1021 1035 * 1022 1036 * @since 5.5.0 … … 1037 1051 ); 1038 1052 1039 // Remove upgrade hooks which are not required for plugin installation tests 1040 // and may interfere with the results due to a timeout in external HTTP requests. 1053 add_filter( 1054 'plugins_api', 1055 function ( $bypass, $action, $args ) { 1056 // Only mock the plugin_information (link-manager) request. 1057 if ( 'plugin_information' !== $action || 'link-manager' !== $args->slug ) { 1058 return $bypass; 1059 } 1060 return self::$plugin_api_decoded_response; 1061 }, 1062 10, 1063 3 1064 ); 1065 1066 /* 1067 * Remove upgrade hooks which are not required for plugin installation tests 1068 * and may interfere with the results due to a timeout in external HTTP requests. 1069 */ 1041 1070 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1042 1071 remove_action( 'upgrader_process_complete', 'wp_version_check' );
Note: See TracChangeset
for help on using the changeset viewer.