- Timestamp:
- 09/06/2022 10:09:49 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r54086 r54090 186 186 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 187 187 // Single. 188 $attachment_id = $this->factory->attachment->create_object(188 $attachment_id = self::factory()->attachment->create_object( 189 189 $this->test_file, 190 190 0, … … 247 247 248 248 public function test_registered_get_item_params() { 249 $id1 = $this->factory->attachment->create_object(249 $id1 = self::factory()->attachment->create_object( 250 250 $this->test_file, 251 251 0, … … 267 267 */ 268 268 public function test_allow_header_sent_on_options_request() { 269 $id1 = $this->factory->attachment->create_object(269 $id1 = self::factory()->attachment->create_object( 270 270 $this->test_file, 271 271 0, … … 295 295 public function test_get_items() { 296 296 wp_set_current_user( 0 ); 297 $id1 = $this->factory->attachment->create_object(298 $this->test_file, 299 0, 300 array( 301 'post_mime_type' => 'image/jpeg', 302 'post_excerpt' => 'A sample caption', 303 ) 304 ); 305 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );306 $id2 = $this->factory->attachment->create_object(297 $id1 = self::factory()->attachment->create_object( 298 $this->test_file, 299 0, 300 array( 301 'post_mime_type' => 'image/jpeg', 302 'post_excerpt' => 'A sample caption', 303 ) 304 ); 305 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 306 $id2 = self::factory()->attachment->create_object( 307 307 $this->test_file, 308 308 $draft_post, … … 312 312 ) 313 313 ); 314 $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );315 $id3 = $this->factory->attachment->create_object(314 $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 315 $id3 = self::factory()->attachment->create_object( 316 316 $this->test_file, 317 317 $published_post, … … 335 335 public function test_get_items_logged_in_editor() { 336 336 wp_set_current_user( self::$editor_id ); 337 $id1 = $this->factory->attachment->create_object(338 $this->test_file, 339 0, 340 array( 341 'post_mime_type' => 'image/jpeg', 342 'post_excerpt' => 'A sample caption', 343 ) 344 ); 345 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );346 $id2 = $this->factory->attachment->create_object(337 $id1 = self::factory()->attachment->create_object( 338 $this->test_file, 339 0, 340 array( 341 'post_mime_type' => 'image/jpeg', 342 'post_excerpt' => 'A sample caption', 343 ) 344 ); 345 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 346 $id2 = self::factory()->attachment->create_object( 347 347 $this->test_file, 348 348 $draft_post, … … 352 352 ) 353 353 ); 354 $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );355 $id3 = $this->factory->attachment->create_object(354 $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 355 $id3 = self::factory()->attachment->create_object( 356 356 $this->test_file, 357 357 $published_post, … … 373 373 374 374 public function test_get_items_media_type() { 375 $id1 = $this->factory->attachment->create_object(375 $id1 = self::factory()->attachment->create_object( 376 376 $this->test_file, 377 377 0, … … 396 396 397 397 public function test_get_items_mime_type() { 398 $id1 = $this->factory->attachment->create_object(398 $id1 = self::factory()->attachment->create_object( 399 399 $this->test_file, 400 400 0, … … 419 419 420 420 public function test_get_items_parent() { 421 $post_id = $this->factory->post->create( array( 'post_title' => 'Test Post' ) );422 $attachment_id = $this->factory->attachment->create_object(421 $post_id = self::factory()->post->create( array( 'post_title' => 'Test Post' ) ); 422 $attachment_id = self::factory()->attachment->create_object( 423 423 $this->test_file, 424 424 $post_id, … … 428 428 ) 429 429 ); 430 $attachment_id2 = $this->factory->attachment->create_object(430 $attachment_id2 = self::factory()->attachment->create_object( 431 431 $this->test_file, 432 432 0, … … 464 464 public function test_get_items_invalid_status_param_is_error_response() { 465 465 wp_set_current_user( self::$editor_id ); 466 $this->factory->attachment->create_object(466 self::factory()->attachment->create_object( 467 467 $this->test_file, 468 468 0, … … 482 482 // Logged out users can't make the request. 483 483 wp_set_current_user( 0 ); 484 $attachment_id1 = $this->factory->attachment->create_object(484 $attachment_id1 = self::factory()->attachment->create_object( 485 485 $this->test_file, 486 486 0, … … 506 506 // Logged out users can't make the request. 507 507 wp_set_current_user( 0 ); 508 $attachment_id1 = $this->factory->attachment->create_object(508 $attachment_id1 = self::factory()->attachment->create_object( 509 509 $this->test_file, 510 510 0, … … 515 515 ) 516 516 ); 517 $attachment_id2 = $this->factory->attachment->create_object(517 $attachment_id2 = self::factory()->attachment->create_object( 518 518 $this->test_file, 519 519 0, … … 551 551 552 552 public function test_get_items_valid_date() { 553 $id1 = $this->factory->attachment->create_object(553 $id1 = self::factory()->attachment->create_object( 554 554 $this->test_file, 555 555 0, … … 560 560 ) 561 561 ); 562 $id2 = $this->factory->attachment->create_object(562 $id2 = self::factory()->attachment->create_object( 563 563 $this->test_file, 564 564 0, … … 569 569 ) 570 570 ); 571 $id3 = $this->factory->attachment->create_object(571 $id3 = self::factory()->attachment->create_object( 572 572 $this->test_file, 573 573 0, … … 602 602 */ 603 603 public function test_get_items_valid_modified_date() { 604 $id1 = $this->factory->attachment->create_object(604 $id1 = self::factory()->attachment->create_object( 605 605 $this->test_file, 606 606 0, … … 611 611 ) 612 612 ); 613 $id2 = $this->factory->attachment->create_object(613 $id2 = self::factory()->attachment->create_object( 614 614 $this->test_file, 615 615 0, … … 620 620 ) 621 621 ); 622 $id3 = $this->factory->attachment->create_object(622 $id3 = self::factory()->attachment->create_object( 623 623 $this->test_file, 624 624 0, … … 662 662 */ 663 663 public function test_get_items_with_empty_page_runs_count_query_after() { 664 $this->factory->attachment->create_object(664 self::factory()->attachment->create_object( 665 665 $this->test_file, 666 666 0, … … 684 684 685 685 public function test_get_item() { 686 $attachment_id = $this->factory->attachment->create_object(686 $attachment_id = self::factory()->attachment->create_object( 687 687 $this->test_file, 688 688 0, … … 704 704 */ 705 705 public function test_get_item_sizes() { 706 $attachment_id = $this->factory->attachment->create_object(706 $attachment_id = self::factory()->attachment->create_object( 707 707 $this->test_file, 708 708 0, … … 735 735 */ 736 736 public function test_get_item_sizes_with_no_url() { 737 $attachment_id = $this->factory->attachment->create_object(737 $attachment_id = self::factory()->attachment->create_object( 738 738 $this->test_file, 739 739 0, … … 762 762 public function test_get_item_private_post_not_authenticated() { 763 763 wp_set_current_user( 0 ); 764 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );765 $id1 = $this->factory->attachment->create_object(764 $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 765 $id1 = self::factory()->attachment->create_object( 766 766 $this->test_file, 767 767 $draft_post, … … 777 777 778 778 public function test_get_item_inherit_status_with_invalid_parent() { 779 $attachment_id = $this->factory->attachment->create_object(779 $attachment_id = self::factory()->attachment->create_object( 780 780 $this->test_file, 781 781 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, … … 794 794 795 795 public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { 796 $attachment_id = $this->factory->attachment->create_object(796 $attachment_id = self::factory()->attachment->create_object( 797 797 $this->test_file, 798 798 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, … … 964 964 965 965 public function test_create_item_invalid_edit_permissions() { 966 $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );966 $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); 967 967 wp_set_current_user( self::$author_id ); 968 968 $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); … … 973 973 974 974 public function test_create_item_invalid_upload_permissions() { 975 $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );975 $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); 976 976 wp_set_current_user( self::$uploader_id ); 977 977 $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); … … 982 982 983 983 public function test_create_item_invalid_post_type() { 984 $attachment_id = $this->factory->post->create(984 $attachment_id = self::factory()->post->create( 985 985 array( 986 986 'post_type' => 'attachment', … … 1047 1047 public function test_update_item() { 1048 1048 wp_set_current_user( self::$editor_id ); 1049 $attachment_id = $this->factory->attachment->create_object(1049 $attachment_id = self::factory()->attachment->create_object( 1050 1050 $this->test_file, 1051 1051 0, … … 1076 1076 public function test_update_item_parent() { 1077 1077 wp_set_current_user( self::$editor_id ); 1078 $original_parent = $this->factory->post->create( array() );1079 $attachment_id = $this->factory->attachment->create_object(1078 $original_parent = self::factory()->post->create( array() ); 1079 $attachment_id = self::factory()->attachment->create_object( 1080 1080 $this->test_file, 1081 1081 $original_parent, … … 1090 1090 $this->assertSame( $original_parent, $attachment->post_parent ); 1091 1091 1092 $new_parent = $this->factory->post->create( array() );1092 $new_parent = self::factory()->post->create( array() ); 1093 1093 $request = new WP_REST_Request( 'POST', '/wp/v2/media/' . $attachment_id ); 1094 1094 $request->set_param( 'post', $new_parent ); … … 1101 1101 public function test_update_item_invalid_permissions() { 1102 1102 wp_set_current_user( self::$author_id ); 1103 $attachment_id = $this->factory->attachment->create_object(1103 $attachment_id = self::factory()->attachment->create_object( 1104 1104 $this->test_file, 1105 1105 0, … … 1117 1117 1118 1118 public function test_update_item_invalid_post_type() { 1119 $attachment_id = $this->factory->post->create(1119 $attachment_id = self::factory()->post->create( 1120 1120 array( 1121 1121 'post_type' => 'attachment', … … 1125 1125 ); 1126 1126 wp_set_current_user( self::$editor_id ); 1127 $attachment_id = $this->factory->attachment->create_object(1127 $attachment_id = self::factory()->attachment->create_object( 1128 1128 $this->test_file, 1129 1129 0, … … 1449 1449 public function test_delete_item() { 1450 1450 wp_set_current_user( self::$editor_id ); 1451 $attachment_id = $this->factory->attachment->create_object(1451 $attachment_id = self::factory()->attachment->create_object( 1452 1452 $this->test_file, 1453 1453 0, … … 1465 1465 public function test_delete_item_no_trash() { 1466 1466 wp_set_current_user( self::$editor_id ); 1467 $attachment_id = $this->factory->attachment->create_object(1467 $attachment_id = self::factory()->attachment->create_object( 1468 1468 $this->test_file, 1469 1469 0, … … 1490 1490 public function test_delete_item_invalid_delete_permissions() { 1491 1491 wp_set_current_user( self::$author_id ); 1492 $attachment_id = $this->factory->attachment->create_object(1492 $attachment_id = self::factory()->attachment->create_object( 1493 1493 $this->test_file, 1494 1494 0, … … 1505 1505 1506 1506 public function test_prepare_item() { 1507 $attachment_id = $this->factory->attachment->create_object(1507 $attachment_id = self::factory()->attachment->create_object( 1508 1508 $this->test_file, 1509 1509 0, … … 1524 1524 1525 1525 public function test_prepare_item_limit_fields() { 1526 $attachment_id = $this->factory->attachment->create_object(1526 $attachment_id = self::factory()->attachment->create_object( 1527 1527 $this->test_file, 1528 1528 0, … … 1615 1615 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1616 1616 1617 $attachment_id = $this->factory->attachment->create_object(1617 $attachment_id = self::factory()->attachment->create_object( 1618 1618 $this->test_file, 1619 1619 0, … … 1652 1652 1653 1653 wp_set_current_user( self::$editor_id ); 1654 $attachment_id = $this->factory->attachment->create_object(1654 $attachment_id = self::factory()->attachment->create_object( 1655 1655 $this->test_file, 1656 1656 0, … … 1678 1678 1679 1679 public function test_search_item_by_filename() { 1680 $id1 = $this->factory->attachment->create_object(1681 $this->test_file, 1682 0, 1683 array( 1684 'post_mime_type' => 'image/jpeg', 1685 ) 1686 ); 1687 $id2 = $this->factory->attachment->create_object(1680 $id1 = self::factory()->attachment->create_object( 1681 $this->test_file, 1682 0, 1683 array( 1684 'post_mime_type' => 'image/jpeg', 1685 ) 1686 ); 1687 $id2 = self::factory()->attachment->create_object( 1688 1688 $this->test_file2, 1689 1689 0, … … 1936 1936 1937 1937 wp_set_current_user( self::$editor_id ); 1938 $attachment_id = $this->factory->attachment->create_object(1938 $attachment_id = self::factory()->attachment->create_object( 1939 1939 $this->test_file, 1940 1940 0,
Note: See TracChangeset
for help on using the changeset viewer.