@@ -144,7 +144,12 @@ protected function helper_get_image( $size = 'large', $meta = true ) {
144
144
add_image_size ( 'jetpack_hard_undefined_zero ' , 700 , 0 , true );
145
145
add_image_size ( 'jetpack_soft_oversized ' , 2000 , 2000 , false );
146
146
147
- $ test_image = self ::create_upload_object ( $ filename , 0 , $ meta );
147
+ try {
148
+ $ test_image = self ::create_upload_object ( $ filename , 0 , $ meta );
149
+ } catch ( Exception $ e ) {
150
+ $ this ->markTestSkipped ( 'Unable to create test image: ' . $ e ->getMessage () );
151
+ return 0 ;
152
+ }
148
153
149
154
// add sizes that did not exist when the file was uploaded.
150
155
// These perfectly match the above and Photon should treat them the same.
@@ -1364,6 +1369,9 @@ public function test_image_cdn_cdn_in_rest_response_with_view_context() {
1364
1369
$ response = rest_get_server ()->dispatch ( $ request );
1365
1370
$ data = $ response ->get_data ();
1366
1371
1372
+ // Convert data to array to ensure consistent access
1373
+ $ data = json_decode ( json_encode ( $ data ), true );
1374
+
1367
1375
$ this ->assertArrayHasKey ( 'media_details ' , $ data );
1368
1376
$ this ->assertArrayHasKey ( 'sizes ' , $ data ['media_details ' ] );
1369
1377
$ this ->assertArrayHasKey ( 'full ' , $ data ['media_details ' ]['sizes ' ] );
@@ -1389,6 +1397,9 @@ public function test_image_cdn_cdn_in_rest_response_with_view_context_from_edito
1389
1397
$ response = rest_get_server ()->dispatch ( $ request );
1390
1398
$ data = $ response ->get_data ();
1391
1399
1400
+ // Convert data to array
1401
+ $ data = json_decode ( json_encode ( $ data ), true );
1402
+
1392
1403
$ this ->assertArrayHasKey ( 'media_details ' , $ data );
1393
1404
$ this ->assertArrayHasKey ( 'sizes ' , $ data ['media_details ' ] );
1394
1405
$ this ->assertArrayHasKey ( 'full ' , $ data ['media_details ' ]['sizes ' ] );
@@ -1404,6 +1415,7 @@ public function test_image_cdn_cdn_in_rest_response_with_view_context_from_edito
1404
1415
$ request ->set_query_params ( array ( 'context ' => 'view ' ) );
1405
1416
$ response = rest_get_server ()->dispatch ( $ request );
1406
1417
$ data = $ response ->get_data ();
1418
+ $ data = json_decode ( json_encode ( $ data ), true );
1407
1419
1408
1420
$ this ->assertArrayHasKey ( 'media_details ' , $ data );
1409
1421
$ this ->assertArrayHasKey ( 'sizes ' , $ data ['media_details ' ] );
@@ -1435,6 +1447,9 @@ public function test_image_cdn_in_rest_response_with_edit_context() {
1435
1447
$ response = rest_get_server ()->dispatch ( $ request );
1436
1448
$ data = $ response ->get_data ();
1437
1449
1450
+ // Convert data to array
1451
+ $ data = json_decode ( json_encode ( $ data ), true );
1452
+
1438
1453
$ this ->assertArrayHasKey ( 'media_details ' , $ data );
1439
1454
$ this ->assertArrayHasKey ( 'sizes ' , $ data ['media_details ' ] );
1440
1455
$ this ->assertArrayHasKey ( 'full ' , $ data ['media_details ' ]['sizes ' ] );
@@ -1450,6 +1465,7 @@ public function test_image_cdn_in_rest_response_with_edit_context() {
1450
1465
$ request ->set_query_params ( array ( 'context ' => 'view ' ) );
1451
1466
$ response = rest_get_server ()->dispatch ( $ request );
1452
1467
$ data = $ response ->get_data ();
1468
+ $ data = json_decode ( json_encode ( $ data ), true );
1453
1469
1454
1470
$ this ->assertArrayHasKey ( 'media_details ' , $ data );
1455
1471
$ this ->assertArrayHasKey ( 'sizes ' , $ data ['media_details ' ] );
@@ -1466,7 +1482,7 @@ public function test_image_cdn_in_rest_response_with_edit_context() {
1466
1482
* Verifies that the REST API upload endpoint does not return with Photon URLs.
1467
1483
*
1468
1484
* The endpoint sets the context to edit, but not before the callback executes.
1469
-
1485
+ *
1470
1486
* @author kraftbj
1471
1487
* @group rest-api
1472
1488
*/
@@ -1485,6 +1501,9 @@ public function test_image_cdn_cdn_in_rest_response_with_created_item() {
1485
1501
// Pull the response from the API.
1486
1502
$ data = $ response ->get_data ();
1487
1503
1504
+ // Convert data to array
1505
+ $ data = json_decode ( json_encode ( $ data ), true );
1506
+
1488
1507
// This verifies the file has uploaded. Just a bit of defensive testing.
1489
1508
$ this ->assertEquals ( 201 , $ response ->get_status () );
1490
1509
0 commit comments