File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
plugins/performance-lab/tests/includes/site-health/audit-enqueued-assets Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -320,31 +320,30 @@ public function mock_requests(): void {
320320 remove_all_filters ( 'pre_http_request ' );
321321 add_filter (
322322 'pre_http_request ' ,
323- static function ( $ preempt , $ parsed_args ) use ( $ mock_html ) {
324- // Mock a HEAD request to return a content length header .
325- if ( isset ( $ parsed_args [ ' method ' ] ) && ' HEAD ' === $ parsed_args [ ' method ' ] ) {
323+ static function ( $ preempt , $ parsed_args, $ url ) use ( $ mock_html ) {
324+ // Mock GET request for the home page to return mocked HTML content .
325+ if ( home_url ( ' / ' ) === $ url ) {
326326 return array (
327327 'response ' => array (
328328 'code ' => 200 ,
329329 ),
330- 'body ' => '' ,
331- 'headers ' => array (
332- 'content-length ' => '10000 ' , // Mocked size of the asset.
333- ),
330+ 'body ' => $ mock_html ,
331+ 'headers ' => array (),
334332 );
335333 }
336334
337- // Mock a GET request to return the HTML content.
335+ // This simulates downloading the actual asset content.
336+ $ mock_asset_content = str_repeat ( 'A ' , 5000 );
338337 return array (
339338 'response ' => array (
340339 'code ' => 200 ,
341340 ),
342- 'body ' => $ mock_html ,
341+ 'body ' => $ mock_asset_content ,
343342 'headers ' => array (),
344343 );
345344 },
346345 10 ,
347- 2
346+ 3
348347 );
349348 }
350349}
You can’t perform that action at this time.
0 commit comments