| | 1146 | public function test_search_item_by_filename() { |
| | 1147 | $this->factory->attachment->create_object( $this->test_file, 0, array( |
| | 1148 | 'post_mime_type' => 'image/jpeg', |
| | 1149 | ) ); |
| | 1150 | $this->factory->attachment->create_object( $this->test_file2, 0, array( |
| | 1151 | 'post_mime_type' => 'image/png', |
| | 1152 | ) ); |
| | 1153 | |
| | 1154 | $filename = basename( $this->test_file2 ); |
| | 1155 | |
| | 1156 | $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); |
| | 1157 | $request->set_param( 'search', $filename ); |
| | 1158 | $response = $this->server->dispatch( $request ); |
| | 1159 | $data = $response->get_data(); |
| | 1160 | |
| | 1161 | $this->assertCount( 1, $data ); |
| | 1162 | $this->assertArrayHasKey( 0, $data ); |
| | 1163 | $this->assertEquals( 'image/png', $data[0]['mime_type'] ); |
| | 1164 | } |
| | 1165 | |