@@ -284,11 +284,15 @@ public function test_perflab_aea_enqueued_blocking_assets_test_but_one_style_is_
284
284
*/
285
285
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthenticated_without_nonce (): void {
286
286
$ this ->add_filter_to_mock_front_page_loopback_request ();
287
- $ this ->expectException ( WPAjaxDieStopException::class );
288
- $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
289
- $ response = json_decode ( $ this ->_last_response , true );
290
- $ this ->assertArrayHasKey ( 'success ' , $ response );
291
- $ this ->assertFalse ( $ response ['success ' ] );
287
+ $ exception = null ;
288
+ try {
289
+ $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
290
+ } catch ( Exception $ e ) {
291
+ $ exception = $ e ;
292
+ }
293
+ $ this ->assertInstanceOf ( WPAjaxDieStopException::class, $ exception );
294
+ $ this ->assertEquals ( '-1 ' , $ exception ->getMessage () );
295
+ $ this ->assertSame ( '' , $ this ->_last_response );
292
296
}
293
297
294
298
/**
@@ -299,8 +303,14 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthentica
299
303
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthenticated_with_nonce (): void {
300
304
$ this ->add_filter_to_mock_front_page_loopback_request ();
301
305
$ _GET ['_wpnonce ' ] = wp_create_nonce ( 'health-check-site-status ' );
302
- $ this ->expectException ( WPAjaxDieContinueException::class );
303
- $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
306
+ $ exception = null ;
307
+ try {
308
+ $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
309
+ } catch ( Exception $ e ) {
310
+ $ exception = $ e ;
311
+ }
312
+ $ this ->assertInstanceOf ( WPAjaxDieContinueException::class, $ exception );
313
+ $ this ->assertEquals ( '' , $ exception ->getMessage () );
304
314
$ response = json_decode ( $ this ->_last_response , true );
305
315
$ this ->assertFalse ( $ response ['success ' ] );
306
316
}
@@ -314,8 +324,14 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthorized
314
324
$ this ->add_filter_to_mock_front_page_loopback_request ();
315
325
wp_set_current_user ( self ::factory ()->user ->create ( array ( 'role ' => 'subscriber ' ) ) );
316
326
$ _GET ['_wpnonce ' ] = wp_create_nonce ( 'health-check-site-status ' );
317
- $ this ->expectException ( WPAjaxDieContinueException::class );
318
- $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
327
+ $ exception = null ;
328
+ try {
329
+ $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
330
+ } catch ( Exception $ e ) {
331
+ $ exception = $ e ;
332
+ }
333
+ $ this ->assertInstanceOf ( WPAjaxDieContinueException::class, $ exception );
334
+ $ this ->assertEquals ( '' , $ exception ->getMessage () );
319
335
$ response = json_decode ( $ this ->_last_response , true );
320
336
$ this ->assertFalse ( $ response ['success ' ] );
321
337
}
@@ -329,10 +345,21 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_authorized()
329
345
$ this ->add_filter_to_mock_front_page_loopback_request ();
330
346
wp_set_current_user ( self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) ) );
331
347
$ _GET ['_wpnonce ' ] = wp_create_nonce ( 'health-check-site-status ' );
332
- $ this ->expectException ( WPAjaxDieContinueException::class );
333
- $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
348
+ $ exception = null ;
349
+ try {
350
+ $ this ->_handleAjax ( 'health-check-enqueued-blocking-assets-test ' );
351
+ } catch ( Exception $ e ) {
352
+ $ exception = $ e ;
353
+ }
354
+ $ this ->assertInstanceOf ( WPAjaxDieContinueException::class, $ exception );
355
+ $ this ->assertEquals ( '' , $ exception ->getMessage () );
334
356
$ response = json_decode ( $ this ->_last_response , true );
335
357
$ this ->assertTrue ( $ response ['success ' ] );
358
+ $ this ->assertArrayHasKey ( 'data ' , $ response );
359
+ $ this ->assertSameSets (
360
+ array ( 'label ' , 'status ' , 'badge ' , 'description ' , 'actions ' , 'test ' ),
361
+ array_keys ( $ response ['data ' ] )
362
+ );
336
363
}
337
364
338
365
/**
0 commit comments