@@ -522,11 +522,7 @@ public function test_get_items_multiple_media_types() {
522522 // Test invalid media type mixed with valid ones.
523523 $ request ->set_param ( 'media_type ' , 'image,invalid,video ' );
524524 $ response = rest_get_server ()->dispatch ( $ request );
525- $ data = $ response ->get_data ();
526- $ this ->assertCount ( 2 , $ data , 'Response count for multiple media types with comma-separated string is not 2 ' );
527- $ ids = wp_list_pluck ( $ data , 'id ' );
528- $ this ->assertContains ( $ image_id , $ ids , 'Image ID not found in response for multiple media types with comma-separated string and invalid media type ' );
529- $ this ->assertContains ( $ video_id , $ ids , 'Video ID not found in response for multiple media types with comma-separated string and invalid media type ' );
525+ $ this ->assertErrorResponse ( 'rest_invalid_param ' , $ response , 400 );
530526 }
531527
532528 /**
@@ -559,14 +555,6 @@ public function test_get_items_multiple_mime_types_and_combination() {
559555 )
560556 );
561557
562- $ rtf_id = self ::factory ()->attachment ->create_object (
563- self ::$ test_rtf_file ,
564- 0 ,
565- array (
566- 'post_mime_type ' => 'application/rtf ' ,
567- )
568- );
569-
570558 $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/media ' );
571559
572560 // Test single MIME type
@@ -595,18 +583,10 @@ public function test_get_items_multiple_mime_types_and_combination() {
595583 $ this ->assertContains ( $ jpeg_id , $ ids , 'JPEG ID not found in response for multiple MIME types with array format ' );
596584 $ this ->assertContains ( $ mp4_id , $ ids , 'MP4 ID not found in response for multiple MIME types with array format ' );
597585
598- // Test multiple media types with multiple MIME types.
599- $ request ->set_param ( 'media_type ' , 'image,video ' );
600- $ request ->set_param ( 'mime_type ' , 'application/rtf ' );
586+ // Test invalid mime type mixed with valid ones.
587+ $ request ->set_param ( 'mime_type ' , array ( 'video/mp4 ' , 'cat/gif ' ) );
601588 $ response = rest_get_server ()->dispatch ( $ request );
602- $ data = $ response ->get_data ();
603-
604- $ this ->assertCount ( 4 , $ data , 'Response count for multiple media types with multiple MIME types is not 4 ' );
605- $ ids = wp_list_pluck ( $ data , 'id ' );
606- $ this ->assertContains ( $ jpeg_id , $ ids , 'JPEG ID not found in response for multiple media types with multiple MIME types ' );
607- $ this ->assertContains ( $ png_id , $ ids , 'PNG ID not found in response for multiple media types with multiple MIME types ' );
608- $ this ->assertContains ( $ mp4_id , $ ids , 'MP4 ID not found in response for multiple media types with multiple MIME types ' );
609- $ this ->assertContains ( $ rtf_id , $ ids , 'RTF ID not found in response for multiple media types with multiple MIME types ' );
589+ $ this ->assertErrorResponse ( 'rest_invalid_param ' , $ response , 400 );
610590 }
611591
612592 /**
@@ -649,6 +629,14 @@ public function test_get_items_with_media_type_and_media_types() {
649629 )
650630 );
651631
632+ $ rtf_id = self ::factory ()->attachment ->create_object (
633+ self ::$ test_rtf_file ,
634+ 0 ,
635+ array (
636+ 'post_mime_type ' => 'application/rtf ' ,
637+ )
638+ );
639+
652640 // Test combination of single media type and single mime type parameters.
653641 $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/media ' );
654642 $ request ->set_param ( 'media_type ' , 'image ' );
@@ -691,16 +679,17 @@ public function test_get_items_with_media_type_and_media_types() {
691679 // Test combination of multiple media types and multiple mime type parameters.
692680 $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/media ' );
693681 $ request ->set_param ( 'media_type ' , 'audio,video ' );
694- $ request ->set_param ( 'mime_type ' , array ( 'image/jpeg ' , 'image/png ' ) );
682+ $ request ->set_param ( 'mime_type ' , array ( 'image/jpeg ' , 'image/png ' , ' application/rtf ' ) );
695683 $ response = rest_get_server ()->dispatch ( $ request );
696684 $ data = $ response ->get_data ();
697685 $ ids = wp_list_pluck ( $ data , 'id ' );
698686
699- $ this ->assertCount ( 4 , $ data , 'Response count for combination of multiple media type and multiple mime type parameters is not 3 ' );
687+ $ this ->assertCount ( 5 , $ data , 'Response count for combination of multiple media type and multiple mime type parameters is not 3 ' );
700688 $ this ->assertContains ( $ audio_id , $ ids , 'Audio ID not found in response ' );
701689 $ this ->assertContains ( $ jpeg_id , $ ids , 'JPEG ID not found in response ' );
702690 $ this ->assertContains ( $ video_id , $ ids , 'Video ID not found in response ' );
703691 $ this ->assertContains ( $ png_id , $ ids , 'PNG ID not found in response ' );
692+ $ this ->assertContains ( $ rtf_id , $ ids , 'RTF ID not found in response ' );
704693 }
705694
706695 public function test_get_items_mime_type () {
0 commit comments