@@ 196-213 (lines=18) @@ | ||
193 | $this->assertTrue( in_array( $id3, $ids ) ); |
|
194 | } |
|
195 | ||
196 | public function test_get_items_media_type() { |
|
197 | $id1 = $this->factory->attachment->create_object( $this->test_file, 0, array( |
|
198 | 'post_mime_type' => 'image/jpeg', |
|
199 | ) ); |
|
200 | $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); |
|
201 | $response = $this->server->dispatch( $request ); |
|
202 | $data = $response->get_data(); |
|
203 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
204 | // media_type=video |
|
205 | $request->set_param( 'media_type', 'video' ); |
|
206 | $response = $this->server->dispatch( $request ); |
|
207 | $this->assertCount( 0, $response->get_data() ); |
|
208 | // media_type=image |
|
209 | $request->set_param( 'media_type', 'image' ); |
|
210 | $response = $this->server->dispatch( $request ); |
|
211 | $data = $response->get_data(); |
|
212 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
213 | } |
|
214 | ||
215 | public function test_get_items_mime_type() { |
|
216 | $id1 = $this->factory->attachment->create_object( $this->test_file, 0, array( |
|
@@ 215-232 (lines=18) @@ | ||
212 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
213 | } |
|
214 | ||
215 | public function test_get_items_mime_type() { |
|
216 | $id1 = $this->factory->attachment->create_object( $this->test_file, 0, array( |
|
217 | 'post_mime_type' => 'image/jpeg', |
|
218 | ) ); |
|
219 | $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); |
|
220 | $response = $this->server->dispatch( $request ); |
|
221 | $data = $response->get_data(); |
|
222 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
223 | // mime_type=image/png |
|
224 | $request->set_param( 'mime_type', 'image/png' ); |
|
225 | $response = $this->server->dispatch( $request ); |
|
226 | $this->assertCount( 0, $response->get_data() ); |
|
227 | // mime_type=image/jpeg |
|
228 | $request->set_param( 'mime_type', 'image/jpeg' ); |
|
229 | $response = $this->server->dispatch( $request ); |
|
230 | $data = $response->get_data(); |
|
231 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
232 | } |
|
233 | ||
234 | public function test_get_items_parent() { |
|
235 | $post_id = $this->factory->post->create( array( 'post_title' => 'Test Post' ) ); |