- Timestamp:
- 10/09/2022 05:45:54 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r54226 r54428 23 23 * @var string The path to a test file. 24 24 */ 25 private $test_file;25 private static $test_file; 26 26 27 27 /** 28 28 * @var string The path to a second test file. 29 29 */ 30 private $test_file2;30 private static $test_file2; 31 31 32 32 /** … … 69 69 70 70 public static function wpTearDownAfterClass() { 71 if ( file_exists( self::$test_file ) ) { 72 unlink( self::$test_file ); 73 } 74 if ( file_exists( self::$test_file2 ) ) { 75 unlink( self::$test_file2 ); 76 } 77 71 78 self::delete_user( self::$editor_id ); 72 79 self::delete_user( self::$author_id ); … … 86 93 87 94 $orig_file = DIR_TESTDATA . '/images/canola.jpg'; 88 $this->test_file = get_temp_dir() . 'canola.jpg'; 89 copy( $orig_file, $this->test_file ); 95 self::$test_file = get_temp_dir() . 'canola.jpg'; 96 if ( ! file_exists( self::$test_file ) ) { 97 copy( $orig_file, self::$test_file ); 98 } 99 90 100 $orig_file2 = DIR_TESTDATA . '/images/codeispoetry.png'; 91 $this->test_file2 = get_temp_dir() . 'codeispoetry.png'; 92 copy( $orig_file2, $this->test_file2 ); 101 self::$test_file2 = get_temp_dir() . 'codeispoetry.png'; 102 if ( ! file_exists( self::$test_file2 ) ) { 103 copy( $orig_file2, self::$test_file2 ); 104 } 93 105 94 106 add_filter( 'rest_pre_dispatch', array( $this, 'wpSetUpBeforeRequest' ), 10, 3 ); … … 107 119 108 120 public function tear_down() { 109 if ( file_exists( $this->test_file ) ) {110 unlink( $this->test_file );111 }112 if ( file_exists( $this->test_file2 ) ) {113 unlink( $this->test_file2 );114 }115 116 121 $this->remove_added_uploads(); 117 122 … … 184 189 // Single. 185 190 $attachment_id = self::factory()->attachment->create_object( 186 $this->test_file,191 self::$test_file, 187 192 0, 188 193 array( … … 245 250 public function test_registered_get_item_params() { 246 251 $id1 = self::factory()->attachment->create_object( 247 $this->test_file,252 self::$test_file, 248 253 0, 249 254 array( … … 265 270 public function test_allow_header_sent_on_options_request() { 266 271 $id1 = self::factory()->attachment->create_object( 267 $this->test_file,272 self::$test_file, 268 273 0, 269 274 array( … … 293 298 wp_set_current_user( 0 ); 294 299 $id1 = self::factory()->attachment->create_object( 295 $this->test_file,300 self::$test_file, 296 301 0, 297 302 array( … … 302 307 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 303 308 $id2 = self::factory()->attachment->create_object( 304 $this->test_file,309 self::$test_file, 305 310 $draft_post, 306 311 array( … … 311 316 $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 312 317 $id3 = self::factory()->attachment->create_object( 313 $this->test_file,318 self::$test_file, 314 319 $published_post, 315 320 array( … … 333 338 wp_set_current_user( self::$editor_id ); 334 339 $id1 = self::factory()->attachment->create_object( 335 $this->test_file,340 self::$test_file, 336 341 0, 337 342 array( … … 342 347 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 343 348 $id2 = self::factory()->attachment->create_object( 344 $this->test_file,349 self::$test_file, 345 350 $draft_post, 346 351 array( … … 351 356 $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 352 357 $id3 = self::factory()->attachment->create_object( 353 $this->test_file,358 self::$test_file, 354 359 $published_post, 355 360 array( … … 371 376 public function test_get_items_media_type() { 372 377 $id1 = self::factory()->attachment->create_object( 373 $this->test_file,378 self::$test_file, 374 379 0, 375 380 array( … … 394 399 public function test_get_items_mime_type() { 395 400 $id1 = self::factory()->attachment->create_object( 396 $this->test_file,401 self::$test_file, 397 402 0, 398 403 array( … … 418 423 $post_id = self::factory()->post->create( array( 'post_title' => 'Test Post' ) ); 419 424 $attachment_id = self::factory()->attachment->create_object( 420 $this->test_file,425 self::$test_file, 421 426 $post_id, 422 427 array( … … 426 431 ); 427 432 $attachment_id2 = self::factory()->attachment->create_object( 428 $this->test_file,433 self::$test_file, 429 434 0, 430 435 array( … … 462 467 wp_set_current_user( self::$editor_id ); 463 468 self::factory()->attachment->create_object( 464 $this->test_file,469 self::$test_file, 465 470 0, 466 471 array( … … 480 485 wp_set_current_user( 0 ); 481 486 $attachment_id1 = self::factory()->attachment->create_object( 482 $this->test_file,487 self::$test_file, 483 488 0, 484 489 array( … … 504 509 wp_set_current_user( 0 ); 505 510 $attachment_id1 = self::factory()->attachment->create_object( 506 $this->test_file,511 self::$test_file, 507 512 0, 508 513 array( … … 513 518 ); 514 519 $attachment_id2 = self::factory()->attachment->create_object( 515 $this->test_file,520 self::$test_file, 516 521 0, 517 522 array( … … 549 554 public function test_get_items_valid_date() { 550 555 $id1 = self::factory()->attachment->create_object( 551 $this->test_file,556 self::$test_file, 552 557 0, 553 558 array( … … 558 563 ); 559 564 $id2 = self::factory()->attachment->create_object( 560 $this->test_file,565 self::$test_file, 561 566 0, 562 567 array( … … 567 572 ); 568 573 $id3 = self::factory()->attachment->create_object( 569 $this->test_file,574 self::$test_file, 570 575 0, 571 576 array( … … 600 605 public function test_get_items_valid_modified_date() { 601 606 $id1 = self::factory()->attachment->create_object( 602 $this->test_file,607 self::$test_file, 603 608 0, 604 609 array( … … 609 614 ); 610 615 $id2 = self::factory()->attachment->create_object( 611 $this->test_file,616 self::$test_file, 612 617 0, 613 618 array( … … 618 623 ); 619 624 $id3 = self::factory()->attachment->create_object( 620 $this->test_file,625 self::$test_file, 621 626 0, 622 627 array( … … 660 665 public function test_get_items_with_empty_page_runs_count_query_after() { 661 666 self::factory()->attachment->create_object( 662 $this->test_file,667 self::$test_file, 663 668 0, 664 669 array( … … 682 687 public function test_get_item() { 683 688 $attachment_id = self::factory()->attachment->create_object( 684 $this->test_file,689 self::$test_file, 685 690 0, 686 691 array( … … 702 707 public function test_get_item_sizes() { 703 708 $attachment_id = self::factory()->attachment->create_object( 704 $this->test_file,709 self::$test_file, 705 710 0, 706 711 array( … … 708 713 'post_excerpt' => 'A sample caption', 709 714 ), 710 $this->test_file715 self::$test_file 711 716 ); 712 717 713 718 add_image_size( 'rest-api-test', 119, 119, true ); 714 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $this->test_file ) );719 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, self::$test_file ) ); 715 720 716 721 $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $attachment_id ); … … 733 738 public function test_get_item_sizes_with_no_url() { 734 739 $attachment_id = self::factory()->attachment->create_object( 735 $this->test_file,740 self::$test_file, 736 741 0, 737 742 array( … … 739 744 'post_excerpt' => 'A sample caption', 740 745 ), 741 $this->test_file746 self::$test_file 742 747 ); 743 748 744 749 add_image_size( 'rest-api-test', 119, 119, true ); 745 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $this->test_file ) );750 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, self::$test_file ) ); 746 751 747 752 add_filter( 'wp_get_attachment_image_src', '__return_false' ); … … 761 766 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 762 767 $id1 = self::factory()->attachment->create_object( 763 $this->test_file,768 self::$test_file, 764 769 $draft_post, 765 770 array( … … 775 780 public function test_get_item_inherit_status_with_invalid_parent() { 776 781 $attachment_id = self::factory()->attachment->create_object( 777 $this->test_file,782 self::$test_file, 778 783 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 779 784 array( … … 792 797 public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { 793 798 $attachment_id = self::factory()->attachment->create_object( 794 $this->test_file,799 self::$test_file, 795 800 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 796 801 array( … … 820 825 $request->set_param( 'alt_text', 'Alt text is stored outside post schema.' ); 821 826 822 $request->set_body( file_get_contents( $this->test_file ) );827 $request->set_body( file_get_contents( self::$test_file ) ); 823 828 $response = rest_get_server()->dispatch( $request ); 824 829 $data = $response->get_data(); … … 844 849 array( 845 850 'file' => array( 846 'file' => file_get_contents( $this->test_file2 ),851 'file' => file_get_contents( self::$test_file2 ), 847 852 'name' => 'codeispoetry.png', 848 'size' => filesize( $this->test_file2 ),849 'tmp_name' => $this->test_file2,853 'size' => filesize( self::$test_file2 ), 854 'tmp_name' => self::$test_file2, 850 855 ), 851 856 ) 852 857 ); 853 $request->set_header( 'Content-MD5', md5_file( $this->test_file2 ) );858 $request->set_header( 'Content-MD5', md5_file( self::$test_file2 ) ); 854 859 $response = rest_get_server()->dispatch( $request ); 855 860 $this->assertSame( 201, $response->get_status() ); … … 867 872 array( 868 873 'file' => array( 869 'file' => file_get_contents( $this->test_file ),874 'file' => file_get_contents( self::$test_file ), 870 875 'name' => 'canola.jpg', 871 'size' => filesize( $this->test_file ),872 'tmp_name' => $this->test_file,876 'size' => filesize( self::$test_file ), 877 'tmp_name' => self::$test_file, 873 878 ), 874 879 ) 875 880 ); 876 $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );881 $request->set_header( 'Content-MD5', md5_file( self::$test_file ) ); 877 882 $response = rest_get_server()->dispatch( $request ); 878 883 $this->assertSame( 201, $response->get_status() ); … … 888 893 array( 889 894 'file' => array( 890 'file' => file_get_contents( $this->test_file ),895 'file' => file_get_contents( self::$test_file ), 891 896 'name' => 'canola.jpg', 892 'size' => filesize( $this->test_file ),893 'tmp_name' => $this->test_file,897 'size' => filesize( self::$test_file ), 898 'tmp_name' => self::$test_file, 894 899 ), 895 900 ) 896 901 ); 897 $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );902 $request->set_header( 'Content-MD5', md5_file( self::$test_file ) ); 898 903 $response = rest_get_server()->dispatch( $request ); 899 904 $this->assertSame( 201, $response->get_status() ); … … 910 915 wp_set_current_user( self::$author_id ); 911 916 $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); 912 $request->set_body( file_get_contents( $this->test_file ) );917 $request->set_body( file_get_contents( self::$test_file ) ); 913 918 $response = rest_get_server()->dispatch( $request ); 914 919 $this->assertErrorResponse( 'rest_upload_no_content_type', $response, 400 ); … … 919 924 $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); 920 925 $request->set_header( 'Content-Type', 'image/jpeg' ); 921 $request->set_body( file_get_contents( $this->test_file ) );926 $request->set_body( file_get_contents( self::$test_file ) ); 922 927 $response = rest_get_server()->dispatch( $request ); 923 928 $this->assertErrorResponse( 'rest_upload_no_content_disposition', $response, 400 ); … … 930 935 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 931 936 $request->set_header( 'Content-MD5', 'abc123' ); 932 $request->set_body( file_get_contents( $this->test_file ) );937 $request->set_body( file_get_contents( self::$test_file ) ); 933 938 $response = rest_get_server()->dispatch( $request ); 934 939 $this->assertErrorResponse( 'rest_upload_hash_mismatch', $response, 412 ); … … 941 946 array( 942 947 'file' => array( 943 'file' => file_get_contents( $this->test_file ),948 'file' => file_get_contents( self::$test_file ), 944 949 'name' => 'canola.jpg', 945 'size' => filesize( $this->test_file ),946 'tmp_name' => $this->test_file,950 'size' => filesize( self::$test_file ), 951 'tmp_name' => self::$test_file, 947 952 ), 948 953 ) … … 990 995 $request->set_header( 'Content-Type', 'image/jpeg' ); 991 996 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 992 $request->set_body( file_get_contents( $this->test_file ) );997 $request->set_body( file_get_contents( self::$test_file ) ); 993 998 $request->set_param( 'post', $attachment_id ); 994 999 $response = rest_get_server()->dispatch( $request ); … … 1005 1010 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1006 1011 1007 $request->set_body( file_get_contents( $this->test_file ) );1012 $request->set_body( file_get_contents( self::$test_file ) ); 1008 1013 $request->set_param( 'alt_text', 'test alt text' ); 1009 1014 $response = rest_get_server()->dispatch( $request ); … … 1020 1025 $request->set_header( 'Content-Type', 'image/jpeg' ); 1021 1026 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1022 $request->set_body( file_get_contents( $this->test_file ) );1027 $request->set_body( file_get_contents( self::$test_file ) ); 1023 1028 $request->set_param( 'alt_text', '<script>alert(document.cookie)</script>' ); 1024 1029 $response = rest_get_server()->dispatch( $request ); … … 1036 1041 $request->set_header( 'Content-Type', 'image/jpeg' ); 1037 1042 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1038 $request->set_body( file_get_contents( $this->test_file ) );1043 $request->set_body( file_get_contents( self::$test_file ) ); 1039 1044 $response = rest_get_server()->dispatch( $request ); 1040 1045 $attachment = $response->get_data(); … … 1045 1050 wp_set_current_user( self::$editor_id ); 1046 1051 $attachment_id = self::factory()->attachment->create_object( 1047 $this->test_file,1052 self::$test_file, 1048 1053 0, 1049 1054 array( … … 1075 1080 $original_parent = self::factory()->post->create( array() ); 1076 1081 $attachment_id = self::factory()->attachment->create_object( 1077 $this->test_file,1082 self::$test_file, 1078 1083 $original_parent, 1079 1084 array( … … 1099 1104 wp_set_current_user( self::$author_id ); 1100 1105 $attachment_id = self::factory()->attachment->create_object( 1101 $this->test_file,1106 self::$test_file, 1102 1107 0, 1103 1108 array( … … 1123 1128 wp_set_current_user( self::$editor_id ); 1124 1129 $attachment_id = self::factory()->attachment->create_object( 1125 $this->test_file,1130 self::$test_file, 1126 1131 0, 1127 1132 array( … … 1144 1149 $parent_id = self::factory()->post->create( array() ); 1145 1150 $attachment_id = self::factory()->attachment->create_object( 1146 $this->test_file,1151 self::$test_file, 1147 1152 $parent_id, 1148 1153 array( … … 1167 1172 wp_set_current_user( self::$editor_id ); 1168 1173 $attachment_id = self::factory()->attachment->create_object( 1169 $this->test_file,1174 self::$test_file, 1170 1175 0, 1171 1176 array( … … 1189 1194 $request->set_header( 'Content-Type', 'image/jpeg' ); 1190 1195 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1191 $request->set_body( file_get_contents( $this->test_file ) );1196 $request->set_body( file_get_contents( self::$test_file ) ); 1192 1197 1193 1198 foreach ( $input as $name => $value ) { … … 1447 1452 wp_set_current_user( self::$editor_id ); 1448 1453 $attachment_id = self::factory()->attachment->create_object( 1449 $this->test_file,1454 self::$test_file, 1450 1455 0, 1451 1456 array( … … 1463 1468 wp_set_current_user( self::$editor_id ); 1464 1469 $attachment_id = self::factory()->attachment->create_object( 1465 $this->test_file,1470 self::$test_file, 1466 1471 0, 1467 1472 array( … … 1488 1493 wp_set_current_user( self::$author_id ); 1489 1494 $attachment_id = self::factory()->attachment->create_object( 1490 $this->test_file,1495 self::$test_file, 1491 1496 0, 1492 1497 array( … … 1503 1508 public function test_prepare_item() { 1504 1509 $attachment_id = self::factory()->attachment->create_object( 1505 $this->test_file,1510 self::$test_file, 1506 1511 0, 1507 1512 array( … … 1522 1527 public function test_prepare_item_limit_fields() { 1523 1528 $attachment_id = self::factory()->attachment->create_object( 1524 $this->test_file,1529 self::$test_file, 1525 1530 0, 1526 1531 array( … … 1613 1618 1614 1619 $attachment_id = self::factory()->attachment->create_object( 1615 $this->test_file,1620 self::$test_file, 1616 1621 0, 1617 1622 array( … … 1650 1655 wp_set_current_user( self::$editor_id ); 1651 1656 $attachment_id = self::factory()->attachment->create_object( 1652 $this->test_file,1657 self::$test_file, 1653 1658 0, 1654 1659 array( … … 1676 1681 public function test_search_item_by_filename() { 1677 1682 $id1 = self::factory()->attachment->create_object( 1678 $this->test_file,1683 self::$test_file, 1679 1684 0, 1680 1685 array( … … 1683 1688 ); 1684 1689 $id2 = self::factory()->attachment->create_object( 1685 $this->test_file2,1690 self::$test_file2, 1686 1691 0, 1687 1692 array( … … 1690 1695 ); 1691 1696 1692 $filename = wp_basename( $this->test_file2 );1697 $filename = wp_basename( self::$test_file2 ); 1693 1698 1694 1699 $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); … … 1802 1807 'file' => array( 1803 1808 'error' => '0', 1804 'file' => file_get_contents( $this->test_file ),1809 'file' => file_get_contents( self::$test_file ), 1805 1810 'name' => 'canola.jpg', 1806 'size' => filesize( $this->test_file ),1807 'tmp_name' => $this->test_file,1811 'size' => filesize( self::$test_file ), 1812 'tmp_name' => self::$test_file, 1808 1813 ), 1809 1814 ) … … 1811 1816 $request->set_param( 'title', 'My title is very cool' ); 1812 1817 $request->set_param( 'caption', 'This is a better caption.' ); 1813 $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );1818 $request->set_header( 'Content-MD5', md5_file( self::$test_file ) ); 1814 1819 1815 1820 $response = rest_get_server()->dispatch( $request ); … … 1830 1835 $request->set_header( 'Content-Type', 'image/jpeg' ); 1831 1836 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1832 $request->set_body( file_get_contents( $this->test_file ) );1837 $request->set_body( file_get_contents( self::$test_file ) ); 1833 1838 $request->set_param( 'title', 'My title is very cool' ); 1834 1839 $request->set_param( 'caption', 'This is a better caption.' ); … … 1853 1858 'file' => array( 1854 1859 'error' => '0', 1855 'file' => file_get_contents( $this->test_file ),1860 'file' => file_get_contents( self::$test_file ), 1856 1861 'name' => 'canola.jpg', 1857 'size' => filesize( $this->test_file ),1858 'tmp_name' => $this->test_file,1862 'size' => filesize( self::$test_file ), 1863 'tmp_name' => self::$test_file, 1859 1864 ), 1860 1865 ) … … 1862 1867 $request->set_param( 'title', 'My title is very cool' ); 1863 1868 $request->set_param( 'caption', 'This is a better caption.' ); 1864 $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );1869 $request->set_header( 'Content-MD5', md5_file( self::$test_file ) ); 1865 1870 1866 1871 $response = rest_get_server()->dispatch( $request ); … … 1881 1886 $request->set_header( 'Content-Type', 'image/jpeg' ); 1882 1887 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1883 $request->set_body( file_get_contents( $this->test_file ) );1888 $request->set_body( file_get_contents( self::$test_file ) ); 1884 1889 $request->set_param( 'title', 'My title is very cool' ); 1885 1890 $request->set_param( 'caption', 'This is a better caption.' ); … … 1911 1916 $request->set_param( 'alt_text', 'Alt text is stored outside post schema.' ); 1912 1917 1913 $request->set_body( file_get_contents( $this->test_file ) );1918 $request->set_body( file_get_contents( self::$test_file ) ); 1914 1919 $response = rest_get_server()->dispatch( $request ); 1915 1920 $data = $response->get_data(); … … 1934 1939 wp_set_current_user( self::$editor_id ); 1935 1940 $attachment_id = self::factory()->attachment->create_object( 1936 $this->test_file,1941 self::$test_file, 1937 1942 0, 1938 1943 array( … … 1972 1977 $request->set_param( 'meta', array( 'best_cannoli' => 'Chocolate-dipped, no filling' ) ); 1973 1978 1974 $request->set_body( file_get_contents( $this->test_file ) );1979 $request->set_body( file_get_contents( self::$test_file ) ); 1975 1980 $response = rest_get_server()->dispatch( $request ); 1976 1981 $data = $response->get_data(); … … 1993 1998 */ 1994 1999 public function test_edit_image_returns_error_if_logged_out() { 1995 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2000 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 1996 2001 1997 2002 $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" ); … … 2010 2015 2011 2016 wp_set_current_user( $user->ID ); 2012 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2017 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2013 2018 2014 2019 $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" ); … … 2024 2029 public function test_edit_image_returns_error_if_cannot_edit() { 2025 2030 wp_set_current_user( self::$uploader_id ); 2026 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2031 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2027 2032 2028 2033 $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" ); … … 2051 2056 public function test_edit_image_returns_error_if_unsupported_mime_type() { 2052 2057 wp_set_current_user( self::$superadmin_id ); 2053 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2058 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2054 2059 wp_update_post( 2055 2060 array( … … 2071 2076 public function test_edit_image_returns_error_if_no_edits() { 2072 2077 wp_set_current_user( self::$superadmin_id ); 2073 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2078 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2074 2079 2075 2080 $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" ); … … 2085 2090 public function test_edit_image_rotate() { 2086 2091 wp_set_current_user( self::$superadmin_id ); 2087 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2092 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2088 2093 2089 2094 $this->setup_mock_editor(); … … 2110 2115 public function test_edit_image_crop() { 2111 2116 wp_set_current_user( self::$superadmin_id ); 2112 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2117 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2113 2118 2114 2119 $this->setup_mock_editor(); … … 2147 2152 public function test_edit_image() { 2148 2153 wp_set_current_user( self::$superadmin_id ); 2149 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2154 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2150 2155 2151 2156 $params = array( … … 2174 2179 public function test_batch_edit_image() { 2175 2180 wp_set_current_user( self::$superadmin_id ); 2176 $attachment = self::factory()->attachment->create_upload_object( $this->test_file );2181 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2177 2182 2178 2183 $params = array( … … 2217 2222 public function test_edit_image_returns_error_if_mismatched_src() { 2218 2223 wp_set_current_user( self::$superadmin_id ); 2219 $attachment_id_image1 = self::factory()->attachment->create_upload_object( $this->test_file );2220 $attachment_id_image2 = self::factory()->attachment->create_upload_object( $this->test_file2 );2224 $attachment_id_image1 = self::factory()->attachment->create_upload_object( self::$test_file ); 2225 $attachment_id_image2 = self::factory()->attachment->create_upload_object( self::$test_file2 ); 2221 2226 $attachment_id_file = self::factory()->attachment->create(); 2222 2227
Note: See TracChangeset
for help on using the changeset viewer.