- Timestamp:
- 11/03/2016 01:45:48 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r39041 r39104 328 328 } 329 329 330 public function test_get_items_multiple_statuses() { 331 // Logged out users can't make the request 332 wp_set_current_user( 0 ); 333 $attachment_id1 = $this->factory->attachment->create_object( $this->test_file, 0, array( 334 'post_mime_type' => 'image/jpeg', 335 'post_excerpt' => 'A sample caption', 336 'post_status' => 'private', 337 ) ); 338 $attachment_id2 = $this->factory->attachment->create_object( $this->test_file, 0, array( 339 'post_mime_type' => 'image/jpeg', 340 'post_excerpt' => 'A sample caption', 341 'post_status' => 'trash', 342 ) ); 343 $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); 344 $request->set_param( 'status', array( 'private', 'trash' ) ); 345 $response = $this->server->dispatch( $request ); 346 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 347 // Properly authorized users can make the request 348 wp_set_current_user( self::$editor_id ); 349 $response = $this->server->dispatch( $request ); 350 $this->assertEquals( 200, $response->get_status() ); 351 $data = $response->get_data(); 352 $this->assertEquals( 2, count( $data ) ); 353 $ids = array( 354 $data[0]['id'], 355 $data[1]['id'], 356 ); 357 sort( $ids ); 358 $this->assertEquals( array( $attachment_id1, $attachment_id2 ), $ids ); 359 } 360 330 361 public function test_get_items_invalid_date() { 331 362 $request = new WP_REST_Request( 'GET', '/wp/v2/media' );
Note: See TracChangeset
for help on using the changeset viewer.