@@ -65,6 +65,33 @@ public function test_get_items() {
6565 $ this ->check_get_posts_response ( $ response );
6666 }
6767
68+ public function test_get_items_logged_in_editor () {
69+ wp_set_current_user ( $ this ->editor_id );
70+ $ id1 = $ this ->factory ->attachment ->create_object ( $ this ->test_file , 0 , array (
71+ 'post_mime_type ' => 'image/jpeg ' ,
72+ 'post_excerpt ' => 'A sample caption ' ,
73+ ) );
74+ $ draft_post = $ this ->factory ->post ->create ( array ( 'post_status ' => 'draft ' ) );
75+ $ id2 = $ this ->factory ->attachment ->create_object ( $ this ->test_file , $ draft_post , array (
76+ 'post_mime_type ' => 'image/jpeg ' ,
77+ 'post_excerpt ' => 'A sample caption ' ,
78+ ) );
79+ $ published_post = $ this ->factory ->post ->create ( array ( 'post_status ' => 'publish ' ) );
80+ $ id3 = $ this ->factory ->attachment ->create_object ( $ this ->test_file , $ published_post , array (
81+ 'post_mime_type ' => 'image/jpeg ' ,
82+ 'post_excerpt ' => 'A sample caption ' ,
83+ ) );
84+ $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/media ' );
85+ $ response = $ this ->server ->dispatch ( $ request );
86+
87+ $ data = $ response ->get_data ();
88+ $ this ->assertCount ( 3 , $ data );
89+ $ ids = wp_list_pluck ( $ data , 'id ' );
90+ $ this ->assertTrue ( in_array ( $ id1 , $ ids ) );
91+ $ this ->assertTrue ( in_array ( $ id2 , $ ids ) );
92+ $ this ->assertTrue ( in_array ( $ id3 , $ ids ) );
93+ }
94+
6895 public function test_get_items_parent () {
6996 $ post_id = $ this ->factory ->post ->create ( array ( 'post_title ' => 'Test Post ' ) );
7097 $ attachment_id = $ this ->factory ->attachment ->create_object ( $ this ->test_file , $ post_id , array (
0 commit comments