- Timestamp:
- 01/26/2021 06:26:13 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r49603 r50024 199 199 'media_type', 200 200 'mime_type', 201 'modified_after', 202 'modified_before', 201 203 'offset', 202 204 'order', … … 561 563 $request->set_param( 'after', '2016-01-15T00:00:00Z' ); 562 564 $request->set_param( 'before', '2016-01-17T00:00:00Z' ); 565 $response = rest_get_server()->dispatch( $request ); 566 $data = $response->get_data(); 567 $this->assertCount( 1, $data ); 568 $this->assertSame( $id2, $data[0]['id'] ); 569 } 570 571 /** 572 * @ticket 50617 573 */ 574 public function test_get_items_invalid_modified_date() { 575 $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); 576 $request->set_param( 'modified_after', rand_str() ); 577 $request->set_param( 'modified_before', rand_str() ); 578 $response = rest_get_server()->dispatch( $request ); 579 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 580 } 581 582 /** 583 * @ticket 50617 584 */ 585 public function test_get_items_valid_modified_date() { 586 $id1 = $this->factory->attachment->create_object( 587 $this->test_file, 588 0, 589 array( 590 'post_date' => '2016-01-01 00:00:00', 591 'post_mime_type' => 'image/jpeg', 592 'post_excerpt' => 'A sample caption', 593 ) 594 ); 595 $id2 = $this->factory->attachment->create_object( 596 $this->test_file, 597 0, 598 array( 599 'post_date' => '2016-01-02 00:00:00', 600 'post_mime_type' => 'image/jpeg', 601 'post_excerpt' => 'A sample caption', 602 ) 603 ); 604 $id3 = $this->factory->attachment->create_object( 605 $this->test_file, 606 0, 607 array( 608 'post_date' => '2016-01-03 00:00:00', 609 'post_mime_type' => 'image/jpeg', 610 'post_excerpt' => 'A sample caption', 611 ) 612 ); 613 $this->update_post_modified( $id1, '2016-01-15 00:00:00' ); 614 $this->update_post_modified( $id2, '2016-01-16 00:00:00' ); 615 $this->update_post_modified( $id3, '2016-01-17 00:00:00' ); 616 $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); 617 $request->set_param( 'modified_after', '2016-01-15T00:00:00Z' ); 618 $request->set_param( 'modified_before', '2016-01-17T00:00:00Z' ); 563 619 $response = rest_get_server()->dispatch( $request ); 564 620 $data = $response->get_data();
Note: See TracChangeset
for help on using the changeset viewer.