Changeset 54090
- Timestamp:
- 09/06/2022 10:09:49 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesScreen.php
r52010 r54090 496 496 497 497 if ( 'post.php' === $hook ) { 498 $post_id = $this->factory->post->create(498 $post_id = self::factory()->post->create( 499 499 array( 500 500 'post_type' => 'type_shows_in_rest', -
trunk/tests/phpunit/tests/admin/includesTheme.php
r53916 r54090 231 231 */ 232 232 public function test_get_theme_featured_list_api() { 233 wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );233 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 234 234 $featured_list_api = get_theme_feature_list( true ); 235 235 $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); -
trunk/tests/phpunit/tests/auth.php
r54088 r54090 408 408 'user_pass' => 'password', 409 409 ); 410 $this->factory->user->create( $user_args );410 self::factory()->user->create( $user_args ); 411 411 412 412 $this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_email'], $user_args['user_pass'] ) ); -
trunk/tests/phpunit/tests/category/walkerCategory.php
r53684 r54090 31 31 public function test_start_el_with_empty_attributes( $value, $expected ) { 32 32 $output = ''; 33 $category = $this->factory->category->create_and_get();33 $category = self::factory()->category->create_and_get(); 34 34 $link = get_term_link( $category ); 35 35 -
trunk/tests/phpunit/tests/comment.php
r53863 r54090 721 721 * Set up a comment for testing. 722 722 */ 723 $post = $this->factory->post->create(723 $post = self::factory()->post->create( 724 724 array( 725 725 'post_author' => self::$user_id, … … 727 727 ); 728 728 729 $comment = $this->factory->comment->create(729 $comment = self::factory()->comment->create( 730 730 array( 731 731 'comment_post_ID' => $post, -
trunk/tests/phpunit/tests/comment/checkComment.php
r54088 r54090 147 147 148 148 // Make sure comment author has an approved comment. 149 $this->factory->comment->create(149 self::factory()->comment->create( 150 150 array( 151 151 'user_id' => $subscriber_id, -
trunk/tests/phpunit/tests/comment/commentsOpen.php
r52223 r54090 18 18 */ 19 19 public function test_post_exist_status_open() { 20 $post = $this->factory->post->create_and_get();20 $post = self::factory()->post->create_and_get(); 21 21 $this->assertTrue( comments_open( $post ) ); 22 22 } … … 26 26 */ 27 27 public function test_post_exist_status_closed() { 28 $post = $this->factory->post->create_and_get();28 $post = self::factory()->post->create_and_get(); 29 29 $post->comment_status = 'closed'; 30 30 -
trunk/tests/phpunit/tests/comment/pingsOpen.php
r52223 r54090 18 18 */ 19 19 public function test_post_exist_status_open() { 20 $post = $this->factory->post->create_and_get();20 $post = self::factory()->post->create_and_get(); 21 21 $this->assertTrue( pings_open( $post ) ); 22 22 } … … 26 26 */ 27 27 public function test_post_exist_status_closed() { 28 $post = $this->factory->post->create_and_get();28 $post = self::factory()->post->create_and_get(); 29 29 $post->ping_status = 'closed'; 30 30 -
trunk/tests/phpunit/tests/comment/template.php
r53863 r54090 59 59 public function test_get_comments_number_text_with_post_id() { 60 60 $post_id = self::$post_id; 61 $this->factory->comment->create_post_comments( $post_id, 6 );61 self::factory()->comment->create_post_comments( $post_id, 6 ); 62 62 63 63 $comments_number_text = get_comments_number_text( false, false, false, $post_id ); … … 85 85 $this->assertSame( __( 'No Comments' ), get_comments_number_text() ); 86 86 87 $this->factory->comment->create_post_comments( $post_id, 1 );87 self::factory()->comment->create_post_comments( $post_id, 1 ); 88 88 $this->go_to( $permalink ); 89 89 90 90 $this->assertSame( __( '1 Comment' ), get_comments_number_text() ); 91 91 92 $this->factory->comment->create_post_comments( $post_id, 1 );92 self::factory()->comment->create_post_comments( $post_id, 1 ); 93 93 $this->go_to( $permalink ); 94 94 … … 107 107 $permalink = get_permalink( $post_id ); 108 108 109 $this->factory->comment->create_post_comments( $post_id, $number );109 self::factory()->comment->create_post_comments( $post_id, $number ); 110 110 $this->go_to( $permalink ); 111 111 -
trunk/tests/phpunit/tests/customize/nav-menus.php
r54088 r54090 418 418 ); 419 419 420 $term_id = $this->factory->term->create(420 $term_id = self::factory()->term->create( 421 421 array( 422 422 'taxonomy' => 'wptests_tax', -
trunk/tests/phpunit/tests/date/getFeedBuildDate.php
r52010 r54090 56 56 $this->assertFalse( get_feed_build_date( DATE_RFC3339 ), 'False when unable to determine valid time' ); 57 57 58 $this->factory->post->create(58 self::factory()->post->create( 59 59 array( 60 60 'post_date' => $datetime->format( 'Y-m-d H:i:s' ), … … 69 69 ); 70 70 71 $post_id_broken = $this->factory->post->create();71 $post_id_broken = self::factory()->post->create(); 72 72 $post_broken = get_post( $post_id_broken ); 73 73 -
trunk/tests/phpunit/tests/date/getTheModifiedDate.php
r50291 r54090 21 21 'post_date_gmt' => '2016-01-21 15:34:36', 22 22 ); 23 $post_id = $this->factory->post->create( $details );23 $post_id = self::factory()->post->create( $details ); 24 24 $format = 'Y-m-d'; 25 25 $expected = '2016-01-21'; … … 40 40 'post_date_gmt' => '2016-01-21 15:34:36', 41 41 ); 42 $post_id = $this->factory->post->create( $details );42 $post_id = self::factory()->post->create( $details ); 43 43 $post = get_post( $post_id ); 44 44 … … 112 112 'post_date_gmt' => '2016-01-21 15:34:36', 113 113 ); 114 $post_id = $this->factory->post->create( $details );114 $post_id = self::factory()->post->create( $details ); 115 115 $format = 'G'; 116 116 $expected = 1453390476; … … 131 131 'post_date_gmt' => '2016-01-21 15:34:36', 132 132 ); 133 $post_id = $this->factory->post->create( $details );133 $post_id = self::factory()->post->create( $details ); 134 134 $post = get_post( $post_id ); 135 135 -
trunk/tests/phpunit/tests/date/xmlrpc.php
r52389 r54090 222 222 223 223 $this->make_user_by_role( 'administrator' ); 224 $post_id = $this->factory->post->create();224 $post_id = self::factory()->post->create(); 225 225 226 226 $comment_data = array( -
trunk/tests/phpunit/tests/general/template.php
r54088 r54090 105 105 */ 106 106 public function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { 107 $blog_id = $this->factory->blog->create();107 $blog_id = self::factory()->blog->create(); 108 108 switch_to_blog( $blog_id ); 109 109 $this->set_site_icon(); … … 120 120 */ 121 121 public function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { 122 $blog_id = $this->factory->blog->create();122 $blog_id = self::factory()->blog->create(); 123 123 124 124 $this->assertFalse( has_site_icon( $blog_id ) ); … … 299 299 */ 300 300 public function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { 301 $blog_id = $this->factory->blog->create();301 $blog_id = self::factory()->blog->create(); 302 302 switch_to_blog( $blog_id ); 303 303 $this->set_custom_logo(); … … 314 314 */ 315 315 public function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { 316 $blog_id = $this->factory->blog->create();316 $blog_id = self::factory()->blog->create(); 317 317 318 318 $this->assertFalse( has_custom_logo( $blog_id ) ); … … 344 344 */ 345 345 public function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { 346 $blog_id = $this->factory->blog->create();346 $blog_id = self::factory()->blog->create(); 347 347 switch_to_blog( $blog_id ); 348 348 … … 467 467 */ 468 468 public function test_get_site_icon_url_preserves_switched_state() { 469 $blog_id = $this->factory->blog->create();469 $blog_id = self::factory()->blog->create(); 470 470 switch_to_blog( $blog_id ); 471 471 … … 487 487 */ 488 488 public function test_has_custom_logo_preserves_switched_state() { 489 $blog_id = $this->factory->blog->create();489 $blog_id = self::factory()->blog->create(); 490 490 switch_to_blog( $blog_id ); 491 491 … … 507 507 */ 508 508 public function test_get_custom_logo_preserves_switched_state() { 509 $blog_id = $this->factory->blog->create();509 $blog_id = self::factory()->blog->create(); 510 510 switch_to_blog( $blog_id ); 511 511 -
trunk/tests/phpunit/tests/general/wpGetDocumentTitle.php
r53815 r54090 102 102 update_option( 103 103 'page_on_front', 104 $this->factory->post->create(104 self::factory()->post->create( 105 105 array( 106 106 'post_title' => 'front-page', … … 129 129 130 130 public function test_home_title() { 131 $blog_page_id = $this->factory->post->create(131 $blog_page_id = self::factory()->post->create( 132 132 array( 133 133 'post_title' => 'blog-page', … … 206 206 ); 207 207 208 $this->factory->post->create(208 self::factory()->post->create( 209 209 array( 210 210 'post_type' => 'cpt', -
trunk/tests/phpunit/tests/image/functions.php
r54086 r54090 659 659 } 660 660 661 $attachment_id = $this->factory->attachment->create_object(661 $attachment_id = self::factory()->attachment->create_object( 662 662 $test_file, 663 663 0, … … 736 736 } 737 737 738 $attachment_id = $this->factory->attachment->create_object(738 $attachment_id = self::factory()->attachment->create_object( 739 739 $test_file, 740 740 0, … … 809 809 } 810 810 811 $attachment_id = $this->factory->attachment->create_object(811 $attachment_id = self::factory()->attachment->create_object( 812 812 $test_file, 813 813 0, … … 883 883 } 884 884 885 $attachment_id = $this->factory->attachment->create_object(885 $attachment_id = self::factory()->attachment->create_object( 886 886 $pdf_path, 887 887 0, -
trunk/tests/phpunit/tests/link/getPostTypeArchiveLink.php
r50454 r54090 20 20 */ 21 21 public function test_get_post_archive_link_with_post_archive_on_a_blog_page() { 22 $page_for_posts = $this->factory->post->create(22 $page_for_posts = self::factory()->post->create( 23 23 array( 24 24 'post_title' => 'blog-page', -
trunk/tests/phpunit/tests/link/getThePrivacyPolicyLink.php
r51462 r54090 116 116 */ 117 117 public function test_function_should_return_empty_string_when_privacy_page_title_empty() { 118 $nameless_page_id = $this->factory->post->create(118 $nameless_page_id = self::factory()->post->create( 119 119 array( 120 120 'post_type' => 'page', -
trunk/tests/phpunit/tests/media/getPostGalleries.php
r53852 r54090 29 29 */ 30 30 public function test_returns_empty_array_with_post_with_no_gallery() { 31 $post_id = $this->factory->post->create(31 $post_id = self::factory()->post->create( 32 32 array( 33 33 'post_content' => '<p>A post with no gallery</p>', … … 50 50 */ 51 51 public function test_returns_only_galleries( $content, $needle ) { 52 $image_id = $this->factory->attachment->create_object(52 $image_id = self::factory()->attachment->create_object( 53 53 array( 54 54 'file' => 'test.jpg', … … 67 67 ); 68 68 69 $post_id = $this->factory->post->create(69 $post_id = self::factory()->post->create( 70 70 array( 71 71 'post_content' => $content, … … 125 125 public function test_returns_no_srcs_with_shortcode_in_post_with_no_attached_images() { 126 126 // Set up an unattached image. 127 $this->factory->attachment->create_object(127 self::factory()->attachment->create_object( 128 128 array( 129 129 'file' => 'test.jpg', … … 134 134 ); 135 135 136 $post_id = $this->factory->post->create(136 $post_id = self::factory()->post->create( 137 137 array( 138 138 'post_content' => '[gallery]', … … 174 174 public function test_returns_no_srcs_with_block_in_post_with_no_attached_images() { 175 175 // Set up an unattached image. 176 $this->factory->attachment->create_object(176 self::factory()->attachment->create_object( 177 177 array( 178 178 'file' => 'test.jpg', … … 183 183 ); 184 184 185 $post_id = $this->factory->post->create(185 $post_id = self::factory()->post->create( 186 186 array( 187 187 'post_content' => '<!-- wp:gallery -->', … … 232 232 public function test_returns_no_srcs_with_block_v2_in_post_with_no_attached_images() { 233 233 // Set up an unattached image. 234 $image_id = $this->factory->attachment->create_object(234 $image_id = self::factory()->attachment->create_object( 235 235 array( 236 236 'file' => 'test.jpg', … … 261 261 BLOB; 262 262 263 $post_id = $this->factory->post->create(263 $post_id = self::factory()->post->create( 264 264 array( 265 265 'post_content' => $blob, … … 310 310 */ 311 311 public function test_returns_html_with_shortcode_gallery() { 312 $post_id = $this->factory->post->create(312 $post_id = self::factory()->post->create( 313 313 array( 314 314 'post_content' => 'I have no gallery', … … 316 316 ); 317 317 318 $post_id_two = $this->factory->post->create(318 $post_id_two = self::factory()->post->create( 319 319 array( 320 320 'post_content' => "[gallery id='$post_id']", … … 322 322 ); 323 323 324 $this->factory->attachment->create_object(324 self::factory()->attachment->create_object( 325 325 array( 326 326 'file' => 'test.jpg', … … 364 364 */ 365 365 public function test_returns_html_with_block_gallery() { 366 $post_id = $this->factory->post->create(366 $post_id = self::factory()->post->create( 367 367 array( 368 368 'post_content' => 'I have no gallery.', … … 371 371 372 372 // Set up an unattached image. 373 $image_id = $this->factory->attachment->create(373 $image_id = self::factory()->attachment->create( 374 374 array( 375 375 'file' => 'test.jpg', … … 388 388 BLOB; 389 389 390 $post_id_two = $this->factory->post->create(390 $post_id_two = self::factory()->post->create( 391 391 array( 392 392 'post_content' => $blob, … … 427 427 */ 428 428 public function test_returns_html_with_block_gallery_v2() { 429 $image_id = $this->factory->attachment->create_object(429 $image_id = self::factory()->attachment->create_object( 430 430 array( 431 431 'file' => 'test.jpg', … … 456 456 BLOB; 457 457 458 $post_id = $this->factory->post->create(458 $post_id = self::factory()->post->create( 459 459 array( 460 460 'post_content' => $blob, … … 496 496 */ 497 497 public function test_respects_post_id_with_shortcode_gallery() { 498 $global_post_id = $this->factory->post->create(498 $global_post_id = self::factory()->post->create( 499 499 array( 500 500 'post_content' => 'Global Post', 501 501 ) 502 502 ); 503 $post_id = $this->factory->post->create(503 $post_id = self::factory()->post->create( 504 504 array( 505 505 'post_content' => '[gallery]', 506 506 ) 507 507 ); 508 $this->factory->attachment->create_object(508 self::factory()->attachment->create_object( 509 509 array( 510 510 'file' => 'test.jpg', … … 578 578 $ids_joined = join( ',', $ids ); 579 579 580 $global_post_id = $this->factory->post->create(580 $global_post_id = self::factory()->post->create( 581 581 array( 582 582 'post_content' => 'Global Post', … … 589 589 BLOB; 590 590 591 $post_id = $this->factory->post->create(591 $post_id = self::factory()->post->create( 592 592 array( 593 593 'post_content' => $blob, 594 594 ) 595 595 ); 596 $this->factory->attachment->create_object(596 self::factory()->attachment->create_object( 597 597 array( 598 598 'file' => 'test.jpg', … … 658 658 $metadata = array_merge( array( 'file' => 'image1.jpg' ), self::IMG_META ); 659 659 $url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . 'image1.jpg'; 660 $global_post_id = $this->factory->post->create(660 $global_post_id = self::factory()->post->create( 661 661 array( 662 662 'post_content' => 'Global Post', … … 684 684 BLOB; 685 685 686 $post_id = $this->factory->post->create(686 $post_id = self::factory()->post->create( 687 687 array( 688 688 'post_content' => $blob, 689 689 ) 690 690 ); 691 $this->factory->attachment->create_object(691 self::factory()->attachment->create_object( 692 692 array( 693 693 'file' => 'test.jpg', … … 743 743 */ 744 744 public function test_respects_shortcode_id_attribute() { 745 $post_id = $this->factory->post->create(745 $post_id = self::factory()->post->create( 746 746 array( 747 747 'post_content' => 'No gallery defined', 748 748 ) 749 749 ); 750 $post_id_two = $this->factory->post->create(750 $post_id_two = self::factory()->post->create( 751 751 array( 752 752 'post_content' => "[gallery id='$post_id']", 753 753 ) 754 754 ); 755 $this->factory->attachment->create_object(755 self::factory()->attachment->create_object( 756 756 array( 757 757 'file' => 'test.jpg', … … 951 951 public function test_returns_srcs_from_html_with_block_with_no_json_blob() { 952 952 // Set up an unattached image. 953 $image_id = $this->factory->attachment->create_object(953 $image_id = self::factory()->attachment->create_object( 954 954 array( 955 955 'file' => 'test.jpg', … … 973 973 BLOB; 974 974 975 $post_id = $this->factory->post->create(975 $post_id = self::factory()->post->create( 976 976 array( 977 977 'post_content' => $blob, … … 1023 1023 */ 1024 1024 public function test_returns_srcs_with_nested_block_gallery() { 1025 $post_id = $this->factory->post->create(1025 $post_id = self::factory()->post->create( 1026 1026 array( 1027 1027 'post_content' => 'I have no gallery.', 1028 1028 ) 1029 1029 ); 1030 $image_id = $this->factory->attachment->create_object(1030 $image_id = self::factory()->attachment->create_object( 1031 1031 array( 1032 1032 'file' => 'test.jpg', … … 1046 1046 BLOB; 1047 1047 1048 $post_id_two = $this->factory->post->create( array( 'post_content' => $blob ) );1048 $post_id_two = self::factory()->post->create( array( 'post_content' => $blob ) ); 1049 1049 1050 1050 $galleries = get_post_galleries( $post_id_two, false ); -
trunk/tests/phpunit/tests/menu/walker-nav-menu-edit.php
r53948 r54090 41 41 $expected = ''; 42 42 43 $post_id = $this->factory->post->create();43 $post_id = self::factory()->post->create(); 44 44 45 45 $item = array( -
trunk/tests/phpunit/tests/menu/walker-nav-menu.php
r53948 r54090 50 50 public function test_noopener_no_referrer_for_target_blank() { 51 51 $actual = ''; 52 $post_id = $this->factory->post->create();52 $post_id = self::factory()->post->create(); 53 53 $post_title = get_the_title( $post_id ); 54 54 … … 81 81 public function test_start_el_with_empty_attributes( $value, $expected ) { 82 82 $output = ''; 83 $post_id = $this->factory->post->create();83 $post_id = self::factory()->post->create(); 84 84 $post_title = get_the_title( $post_id ); 85 85 -
trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php
r51419 r54090 105 105 register_taxonomy( 'wptests_tax', 'post' ); 106 106 107 $this->factory->term->create(107 self::factory()->term->create( 108 108 array( 109 109 'taxonomy' => 'wptests_tax', -
trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php
r51860 r54090 14 14 */ 15 15 public function test_option_should_not_be_empty_by_default() { 16 $blog_id = $this->factory->blog->create();16 $blog_id = self::factory()->blog->create(); 17 17 18 18 switch_to_blog( $blog_id ); … … 40 40 update_site_option( 'first_comment', '' ); 41 41 42 $blog_id = $this->factory->blog->create();42 $blog_id = self::factory()->blog->create(); 43 43 44 44 switch_to_blog( $blog_id ); … … 66 66 update_site_option( 'first_comment', 'Some comment content' ); 67 67 68 $blog_id = $this->factory->blog->create();68 $blog_id = self::factory()->blog->create(); 69 69 70 70 switch_to_blog( $blog_id ); -
trunk/tests/phpunit/tests/post.php
r54088 r54090 455 455 add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); 456 456 457 $post_id = $this->factory->post->create(457 $post_id = self::factory()->post->create( 458 458 array( 459 459 'title' => 'An example', -
trunk/tests/phpunit/tests/post/walkerPage.php
r51657 r54090 29 29 public function test_start_el_with_empty_attributes( $value, $expected ) { 30 30 $output = ''; 31 $page = $this->factory->post->create_and_get( array( 'post_type' => 'page' ) );31 $page = self::factory()->post->create_and_get( array( 'post_type' => 'page' ) ); 32 32 $link = get_permalink( $page ); 33 33 -
trunk/tests/phpunit/tests/post/wpPublishPost.php
r53783 r54090 143 143 public function test_wp_publish_post_respects_current_categories() { 144 144 $post_id = self::$auto_draft_id; 145 $category_id = $this->factory->term->create( array( 'taxonomy' => 'category' ) );145 $category_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); 146 146 wp_set_post_categories( $post_id, $category_id ); 147 147 wp_publish_post( $post_id ); … … 184 184 public function test_wp_publish_post_adds_default_category_when_tagged() { 185 185 $post_id = self::$auto_draft_id; 186 $tag_id = $this->factory->term->create( array( 'taxonomy' => 'post_tag' ) );186 $tag_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) ); 187 187 wp_set_post_tags( $post_id, array( $tag_id ) ); 188 188 wp_publish_post( $post_id ); … … 219 219 220 220 $post_id = self::$auto_draft_id; 221 $term_id = $this->factory->term->create( array( 'taxonomy' => 'tax_51292' ) );221 $term_id = self::factory()->term->create( array( 'taxonomy' => 'tax_51292' ) ); 222 222 wp_set_object_terms( $post_id, array( $term_id ), 'tax_51292' ); 223 223 wp_publish_post( $post_id ); -
trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php
r51568 r54090 132 132 */ 133 133 public function test_should_send_email_with_privacy_policy() { 134 $privacy_policy = $this->factory->post->create(134 $privacy_policy = self::factory()->post->create( 135 135 array( 136 136 'post_type' => 'page', … … 308 308 */ 309 309 public function test_should_not_send_email_when_not_user_request() { 310 $post_id = $this->factory->post->create(310 $post_id = self::factory()->post->create( 311 311 array( 312 312 'post_type' => 'post', // Should be 'user_request'. -
trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php
r51568 r54090 56 56 */ 57 57 public function test_function_should_not_send_email_when_not_a_wp_user_request() { 58 $post_id = $this->factory->post->create(58 $post_id = self::factory()->post->create( 59 59 array( 60 60 'post_type' => 'post', -
trunk/tests/phpunit/tests/query.php
r53861 r54090 645 645 register_taxonomy( 'tax2', 'post' ); 646 646 647 $term1 = $this->factory->term->create(647 $term1 = self::factory()->term->create( 648 648 array( 649 649 'taxonomy' => 'tax1', … … 651 651 ) 652 652 ); 653 $term2 = $this->factory->term->create(653 $term2 = self::factory()->term->create( 654 654 array( 655 655 'taxonomy' => 'tax2', … … 657 657 ) 658 658 ); 659 $post_id = $this->factory->post->create();659 $post_id = self::factory()->post->create(); 660 660 wp_set_object_terms( $post_id, 'term1', 'tax1' ); 661 661 wp_set_object_terms( $post_id, 'term2', 'tax2' ); … … 675 675 register_taxonomy( 'tax2', 'post' ); 676 676 677 $term1 = $this->factory->term->create(677 $term1 = self::factory()->term->create( 678 678 array( 679 679 'taxonomy' => 'tax1', … … 681 681 ) 682 682 ); 683 $term2 = $this->factory->term->create(683 $term2 = self::factory()->term->create( 684 684 array( 685 685 'taxonomy' => 'tax2', … … 687 687 ) 688 688 ); 689 $post_id = $this->factory->post->create();689 $post_id = self::factory()->post->create(); 690 690 wp_set_object_terms( $post_id, 'term1', 'tax1' ); 691 691 wp_set_object_terms( $post_id, 'term2', 'tax2' ); -
trunk/tests/phpunit/tests/query/conditionals.php
r53429 r54090 979 979 $this->set_permalink_structure( '/%postname%/' ); 980 980 981 $attachment_id = $this->factory->post->create(981 $attachment_id = self::factory()->post->create( 982 982 array( 983 983 'post_type' => 'attachment', … … 985 985 ); 986 986 987 $post_id = $this->factory->post->create(987 $post_id = self::factory()->post->create( 988 988 array( 989 989 'post_title' => get_post( $attachment_id )->post_title, -
trunk/tests/phpunit/tests/query/noFoundRows.php
r51462 r54090 74 74 */ 75 75 public function test_no_found_rows_default_with_nopaging_true() { 76 $p = $this->factory->post->create();76 $p = self::factory()->post->create(); 77 77 78 78 $q = new WP_Query( … … 91 91 */ 92 92 public function test_no_found_rows_default_with_postsperpage_minus1() { 93 $p = $this->factory->post->create();93 $p = self::factory()->post->create(); 94 94 95 95 $q = new WP_Query( -
trunk/tests/phpunit/tests/query/search.php
r52389 r54090 267 267 */ 268 268 public function test_s_zero() { 269 $p1 = $this->factory->post->create(269 $p1 = self::factory()->post->create( 270 270 array( 271 271 'post_status' => 'publish', … … 276 276 ); 277 277 278 $p2 = $this->factory->post->create(278 $p2 = self::factory()->post->create( 279 279 array( 280 280 'post_status' => 'publish', -
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, -
trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php
r53909 r54090 122 122 $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 123 123 // Single. 124 $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );124 $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); 125 125 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 ); 126 126 $response = rest_get_server()->dispatch( $request ); … … 173 173 174 174 public function test_get_items_hide_empty_arg() { 175 $post_id = $this->factory->post->create();176 $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );177 $category2 = $this->factory->category->create( array( 'name' => 'The Be Sharps' ) );175 $post_id = self::factory()->post->create(); 176 $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); 177 $category2 = self::factory()->category->create( array( 'name' => 'The Be Sharps' ) ); 178 178 179 179 $total_categories = self::$total_categories + 2; … … 198 198 199 199 public function test_get_items_parent_zero_arg() { 200 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );201 $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );202 $this->factory->category->create(200 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 201 $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); 202 self::factory()->category->create( 203 203 array( 204 204 'name' => 'Bart', … … 206 206 ) 207 207 ); 208 $this->factory->category->create(208 self::factory()->category->create( 209 209 array( 210 210 'name' => 'Lisa', … … 230 230 231 231 public function test_get_items_parent_zero_arg_string() { 232 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );233 $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );234 $this->factory->category->create(232 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 233 $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); 234 self::factory()->category->create( 235 235 array( 236 236 'name' => 'Bart', … … 238 238 ) 239 239 ); 240 $this->factory->category->create(240 self::factory()->category->create( 241 241 array( 242 242 'name' => 'Lisa', … … 262 262 263 263 public function test_get_items_by_parent_non_found() { 264 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );264 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 265 265 266 266 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 285 285 286 286 public function test_get_items_include_query() { 287 $id1 = $this->factory->category->create();288 $id2 = $this->factory->category->create();287 $id1 = self::factory()->category->create(); 288 $id2 = self::factory()->category->create(); 289 289 290 290 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 306 306 307 307 public function test_get_items_exclude_query() { 308 $id1 = $this->factory->category->create();309 $id2 = $this->factory->category->create();308 $id1 = self::factory()->category->create(); 309 $id2 = self::factory()->category->create(); 310 310 311 311 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 326 326 327 327 public function test_get_items_orderby_args() { 328 $this->factory->category->create( array( 'name' => 'Apple' ) );329 $this->factory->category->create( array( 'name' => 'Banana' ) );328 self::factory()->category->create( array( 'name' => 'Apple' ) ); 329 self::factory()->category->create( array( 'name' => 'Banana' ) ); 330 330 331 331 /* … … 357 357 358 358 public function test_get_items_orderby_id() { 359 $this->factory->category->create( array( 'name' => 'Cantaloupe' ) );360 $this->factory->category->create( array( 'name' => 'Apple' ) );361 $this->factory->category->create( array( 'name' => 'Banana' ) );359 self::factory()->category->create( array( 'name' => 'Cantaloupe' ) ); 360 self::factory()->category->create( array( 'name' => 'Apple' ) ); 361 self::factory()->category->create( array( 'name' => 'Banana' ) ); 362 362 363 363 // Defaults to 'orderby' => 'name', 'order' => 'asc'. … … 393 393 394 394 public function test_get_items_orderby_slugs() { 395 $this->factory->category->create( array( 'name' => 'Burrito' ) );396 $this->factory->category->create( array( 'name' => 'Taco' ) );397 $this->factory->category->create( array( 'name' => 'Chalupa' ) );395 self::factory()->category->create( array( 'name' => 'Burrito' ) ); 396 self::factory()->category->create( array( 'name' => 'Taco' ) ); 397 self::factory()->category->create( array( 'name' => 'Chalupa' ) ); 398 398 399 399 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 409 409 410 410 protected function post_with_categories() { 411 $post_id = $this->factory->post->create();412 $category1 = $this->factory->category->create(411 $post_id = self::factory()->post->create(); 412 $category1 = self::factory()->category->create( 413 413 array( 414 414 'name' => 'DC', … … 416 416 ) 417 417 ); 418 $category2 = $this->factory->category->create(418 $category2 = self::factory()->category->create( 419 419 array( 420 420 'name' => 'Marvel', … … 422 422 ) 423 423 ); 424 $category3 = $this->factory->category->create(424 $category3 = self::factory()->category->create( 425 425 array( 426 426 'name' => 'Image', … … 494 494 $controller = new WP_REST_Terms_Controller( 'batman' ); 495 495 $controller->register_routes(); 496 $term1 = $this->factory->term->create(496 $term1 = self::factory()->term->create( 497 497 array( 498 498 'name' => 'Cape', … … 500 500 ) 501 501 ); 502 $term2 = $this->factory->term->create(502 $term2 = self::factory()->term->create( 503 503 array( 504 504 'name' => 'Mask', … … 506 506 ) 507 507 ); 508 $this->factory->term->create(508 self::factory()->term->create( 509 509 array( 510 510 'name' => 'Car', … … 512 512 ) 513 513 ); 514 $post_id = $this->factory->post->create();514 $post_id = self::factory()->post->create(); 515 515 wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); 516 516 … … 526 526 527 527 public function test_get_items_search_args() { 528 $this->factory->category->create( array( 'name' => 'Apple' ) );529 $this->factory->category->create( array( 'name' => 'Banana' ) );528 self::factory()->category->create( array( 'name' => 'Apple' ) ); 529 self::factory()->category->create( array( 'name' => 'Banana' ) ); 530 530 531 531 /* … … 550 550 551 551 public function test_get_items_slug_arg() { 552 $this->factory->category->create( array( 'name' => 'Apple' ) );553 $this->factory->category->create( array( 'name' => 'Banana' ) );552 self::factory()->category->create( array( 'name' => 'Apple' ) ); 553 self::factory()->category->create( array( 'name' => 'Banana' ) ); 554 554 555 555 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 563 563 564 564 public function test_get_terms_parent_arg() { 565 $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) );566 $this->factory->category->create(565 $category1 = self::factory()->category->create( array( 'name' => 'Parent' ) ); 566 self::factory()->category->create( 567 567 array( 568 568 'name' => 'Child', … … 588 588 public function test_get_terms_private_taxonomy() { 589 589 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 590 $this->factory->term->create(590 self::factory()->term->create( 591 591 array( 592 592 'name' => 'Cape', … … 594 594 ) 595 595 ); 596 $this->factory->term->create(596 self::factory()->term->create( 597 597 array( 598 598 'name' => 'Mask', … … 633 633 634 634 // 3rd page. 635 $this->factory->category->create();635 self::factory()->category->create(); 636 636 $total_categories++; 637 637 $total_pages++; … … 776 776 public function test_get_term_private_taxonomy() { 777 777 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 778 $term1 = $this->factory->term->create(778 $term1 = self::factory()->term->create( 779 779 array( 780 780 'name' => 'Cape', … … 790 790 public function test_get_item_incorrect_taxonomy() { 791 791 register_taxonomy( 'robin', 'post' ); 792 $term1 = $this->factory->term->create(792 $term1 = self::factory()->term->create( 793 793 array( 794 794 'name' => 'Cape', … … 825 825 wp_set_current_user( self::$administrator ); 826 826 827 $existing_id = $this->factory->category->create( array( 'name' => 'Existing' ) );827 $existing_id = self::factory()->category->create( array( 'name' => 'Existing' ) ); 828 828 829 829 $request = new WP_REST_Request( 'POST', '/wp/v2/categories' ); … … 891 891 wp_set_current_user( self::$administrator ); 892 892 893 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );893 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 894 894 895 895 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 923 923 ); 924 924 925 $term = get_term_by( 'id', $this->factory->category->create( $orig_args ), 'category' );925 $term = get_term_by( 'id', self::factory()->category->create( $orig_args ), 'category' ); 926 926 927 927 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 969 969 wp_set_current_user( self::$subscriber ); 970 970 971 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );971 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 972 972 973 973 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 980 980 wp_set_current_user( self::$administrator ); 981 981 982 $parent = get_term_by( 'id', $this->factory->category->create(), 'category' );983 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );982 $parent = get_term_by( 'id', self::factory()->category->create(), 'category' ); 983 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 984 984 985 985 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 995 995 wp_set_current_user( self::$administrator ); 996 996 997 $old_parent_term = get_term_by( 'id', $this->factory->category->create(), 'category' );997 $old_parent_term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 998 998 $new_parent_id = 0; 999 999 1000 1000 $term = get_term_by( 1001 1001 'id', 1002 $this->factory->category->create(1002 self::factory()->category->create( 1003 1003 array( 1004 1004 'parent' => $old_parent_term->term_id, … … 1022 1022 wp_set_current_user( self::$administrator ); 1023 1023 1024 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );1024 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 1025 1025 1026 1026 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 1033 1033 wp_set_current_user( self::$administrator ); 1034 1034 1035 $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );1035 $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); 1036 1036 1037 1037 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); … … 1047 1047 wp_set_current_user( self::$administrator ); 1048 1048 1049 $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );1049 $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); 1050 1050 1051 1051 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); … … 1077 1077 wp_set_current_user( self::$subscriber ); 1078 1078 1079 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );1079 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 1080 1080 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); 1081 1081 $response = rest_get_server()->dispatch( $request ); … … 1109 1109 1110 1110 public function test_prepare_taxonomy_term_child() { 1111 $child = $this->factory->category->create(1111 $child = self::factory()->category->create( 1112 1112 array( 1113 1113 'parent' => 1, … … 1171 1171 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1172 1172 1173 $category_id = $this->factory->category->create();1173 $category_id = self::factory()->category->create(); 1174 1174 $request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $category_id ); 1175 1175 -
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r53909 r54090 238 238 ); 239 239 240 $password_comment = $this->factory->comment->create( $args );240 $password_comment = self::factory()->comment->create( $args ); 241 241 242 242 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 262 262 ); 263 263 264 $password_comment = $this->factory->comment->create( $args );264 $password_comment = self::factory()->comment->create( $args ); 265 265 266 266 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 285 285 ); 286 286 287 $password_comment = $this->factory->comment->create( $args );287 $password_comment = self::factory()->comment->create( $args ); 288 288 289 289 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 303 303 ); 304 304 305 $password_comment = $this->factory->comment->create( $args );305 $password_comment = self::factory()->comment->create( $args ); 306 306 307 307 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 322 322 ); 323 323 324 $password_comment = $this->factory->comment->create( $args );324 $password_comment = self::factory()->comment->create( $args ); 325 325 326 326 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 341 341 ); 342 342 343 $private_comment = $this->factory->comment->create( $args );343 $private_comment = self::factory()->comment->create( $args ); 344 344 345 345 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 360 360 ); 361 361 362 $private_comment = $this->factory->comment->create( $args );362 $private_comment = self::factory()->comment->create( $args ); 363 363 364 364 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 374 374 wp_set_current_user( 0 ); 375 375 376 $comment_id = $this->factory->comment->create(376 $comment_id = self::factory()->comment->create( 377 377 array( 378 378 'comment_approved' => 1, … … 395 395 wp_set_current_user( self::$admin_id ); 396 396 397 $comment_id = $this->factory->comment->create(397 $comment_id = self::factory()->comment->create( 398 398 array( 399 399 'comment_approved' => 1, … … 425 425 wp_set_current_user( self::$admin_id ); 426 426 427 $this->factory->comment->create_post_comments( 0, 2 );427 self::factory()->comment->create_post_comments( 0, 2 ); 428 428 429 429 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 454 454 455 455 public function test_get_items_for_post() { 456 $second_post_id = $this->factory->post->create();457 $this->factory->comment->create_post_comments( $second_post_id, 2 );456 $second_post_id = self::factory()->post->create(); 457 self::factory()->comment->create_post_comments( $second_post_id, 2 ); 458 458 459 459 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 479 479 ); 480 480 481 $id1 = $this->factory->comment->create( $args );482 $id2 = $this->factory->comment->create( $args );481 $id1 = self::factory()->comment->create( $args ); 482 $id2 = self::factory()->comment->create( $args ); 483 483 484 484 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 519 519 ); 520 520 521 $id1 = $this->factory->comment->create( $args );522 $id2 = $this->factory->comment->create( $args );521 $id1 = self::factory()->comment->create( $args ); 522 $id2 = self::factory()->comment->create( $args ); 523 523 524 524 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 575 575 ); 576 576 577 $id = $this->factory->comment->create( $args );577 $id = self::factory()->comment->create( $args ); 578 578 579 579 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 599 599 wp_set_current_user( 0 ); 600 600 601 $post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );601 $post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); 602 602 603 603 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 617 617 ); 618 618 619 $this->factory->comment->create( $args );619 self::factory()->comment->create( $args ); 620 620 $args['user_id'] = self::$subscriber_id; 621 $this->factory->comment->create( $args );621 self::factory()->comment->create( $args ); 622 622 unset( $args['user_id'] ); 623 $this->factory->comment->create( $args );623 self::factory()->comment->create( $args ); 624 624 625 625 // Limit to comment author. … … 660 660 ); 661 661 662 $this->factory->comment->create( $args );662 self::factory()->comment->create( $args ); 663 663 $args['user_id'] = self::$subscriber_id; 664 $this->factory->comment->create( $args );664 self::factory()->comment->create( $args ); 665 665 unset( $args['user_id'] ); 666 $this->factory->comment->create( $args );666 self::factory()->comment->create( $args ); 667 667 668 668 $total_comments = self::$total_comments + 3; … … 710 710 'comment_post_ID' => self::$post_id, 711 711 ); 712 $parent_id = $this->factory->comment->create( $args );713 $parent_id2 = $this->factory->comment->create( $args );712 $parent_id = self::factory()->comment->create( $args ); 713 $parent_id2 = self::factory()->comment->create( $args ); 714 714 $args['comment_parent'] = $parent_id; 715 $this->factory->comment->create( $args );715 self::factory()->comment->create( $args ); 716 716 $args['comment_parent'] = $parent_id2; 717 $this->factory->comment->create( $args );717 self::factory()->comment->create( $args ); 718 718 719 719 $total_comments = self::$total_comments + 4; … … 746 746 'comment_post_ID' => self::$post_id, 747 747 ); 748 $parent_id = $this->factory->comment->create( $args );749 $parent_id2 = $this->factory->comment->create( $args );748 $parent_id = self::factory()->comment->create( $args ); 749 $parent_id2 = self::factory()->comment->create( $args ); 750 750 $args['comment_parent'] = $parent_id; 751 $this->factory->comment->create( $args );751 self::factory()->comment->create( $args ); 752 752 $args['comment_parent'] = $parent_id2; 753 $this->factory->comment->create( $args );753 self::factory()->comment->create( $args ); 754 754 755 755 $total_comments = self::$total_comments + 4; … … 787 787 ); 788 788 789 $id = $this->factory->comment->create( $args );789 $id = self::factory()->comment->create( $args ); 790 790 791 791 $total_comments = self::$total_comments + 1; … … 826 826 827 827 // 3rd page. 828 $this->factory->comment->create(828 self::factory()->comment->create( 829 829 array( 830 830 'comment_post_ID' => self::$post_id, … … 896 896 897 897 public function test_get_comments_valid_date() { 898 $comment1 = $this->factory->comment->create(898 $comment1 = self::factory()->comment->create( 899 899 array( 900 900 'comment_date' => '2016-01-15T00:00:00Z', … … 902 902 ) 903 903 ); 904 $comment2 = $this->factory->comment->create(904 $comment2 = self::factory()->comment->create( 905 905 array( 906 906 'comment_date' => '2016-01-16T00:00:00Z', … … 908 908 ) 909 909 ); 910 $comment3 = $this->factory->comment->create(910 $comment3 = self::factory()->comment->create( 911 911 array( 912 912 'comment_date' => '2016-01-17T00:00:00Z', … … 1004 1004 wp_set_current_user( 0 ); 1005 1005 1006 $comment_id = $this->factory->comment->create(1006 $comment_id = self::factory()->comment->create( 1007 1007 array( 1008 1008 'comment_approved' => 1, … … 1019 1019 wp_set_current_user( self::$admin_id ); 1020 1020 1021 $comment_id = $this->factory->comment->create(1021 $comment_id = self::factory()->comment->create( 1022 1022 array( 1023 1023 'comment_approved' => 1, … … 1048 1048 1049 1049 public function test_get_comment_with_children_link() { 1050 $comment_id_1 = $this->factory->comment->create(1050 $comment_id_1 = self::factory()->comment->create( 1051 1051 array( 1052 1052 'comment_approved' => 1, … … 1056 1056 ); 1057 1057 1058 $child_comment = $this->factory->comment->create(1058 $child_comment = self::factory()->comment->create( 1059 1059 array( 1060 1060 'comment_approved' => 1, … … 1072 1072 1073 1073 public function test_get_comment_without_children_link() { 1074 $comment_id_1 = $this->factory->comment->create(1074 $comment_id_1 = self::factory()->comment->create( 1075 1075 array( 1076 1076 'comment_approved' => 1, … … 1094 1094 ); 1095 1095 1096 $password_comment = $this->factory->comment->create( $args );1096 $password_comment = self::factory()->comment->create( $args ); 1097 1097 1098 1098 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); … … 1112 1112 ); 1113 1113 1114 $password_comment = $this->factory->comment->create( $args );1114 $password_comment = self::factory()->comment->create( $args ); 1115 1115 1116 1116 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); … … 1491 1491 1492 1492 public function test_create_item_assign_different_user() { 1493 $subscriber_id = $this->factory->user->create(1493 $subscriber_id = self::factory()->user->create( 1494 1494 array( 1495 1495 'role' => 'subscriber', … … 1522 1522 1523 1523 public function test_create_comment_without_type() { 1524 $post_id = $this->factory->post->create();1524 $post_id = self::factory()->post->create(); 1525 1525 1526 1526 wp_set_current_user( self::$admin_id ); … … 1560 1560 */ 1561 1561 public function test_create_comment_with_invalid_type() { 1562 $post_id = $this->factory->post->create();1562 $post_id = self::factory()->post->create(); 1563 1563 1564 1564 wp_set_current_user( self::$admin_id ); … … 1584 1584 1585 1585 public function test_create_comment_invalid_email() { 1586 $post_id = $this->factory->post->create();1586 $post_id = self::factory()->post->create(); 1587 1587 1588 1588 wp_set_current_user( self::$admin_id ); … … 1607 1607 1608 1608 public function test_create_item_current_user() { 1609 $user_id = $this->factory->user->create(1609 $user_id = self::factory()->user->create( 1610 1610 array( 1611 1611 'role' => 'subscriber', … … 1729 1729 1730 1730 public function test_create_comment_with_status_IP_and_user_agent() { 1731 $post_id = $this->factory->post->create();1731 $post_id = self::factory()->post->create(); 1732 1732 1733 1733 wp_set_current_user( self::$admin_id ); … … 2007 2007 wp_set_current_user( self::$subscriber_id ); 2008 2008 2009 $this->factory->comment->create(2009 self::factory()->comment->create( 2010 2010 array( 2011 2011 'comment_post_ID' => self::$post_id, … … 2032 2032 2033 2033 public function test_create_comment_closed() { 2034 $post_id = $this->factory->post->create(2034 $post_id = self::factory()->post->create( 2035 2035 array( 2036 2036 'comment_status' => 'closed', … … 2304 2304 2305 2305 public function test_update_item() { 2306 $post_id = $this->factory->post->create();2306 $post_id = self::factory()->post->create(); 2307 2307 2308 2308 wp_set_current_user( self::$admin_id ); … … 2348 2348 update_option( 'timezone_string', $params['timezone_string'] ); 2349 2349 2350 $comment_id = $this->factory->comment->create();2350 $comment_id = self::factory()->comment->create(); 2351 2351 2352 2352 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) ); … … 2375 2375 2376 2376 public function test_update_item_no_content() { 2377 $post_id = $this->factory->post->create();2377 $post_id = self::factory()->post->create(); 2378 2378 2379 2379 wp_set_current_user( self::$admin_id ); … … 2413 2413 wp_set_current_user( self::$admin_id ); 2414 2414 2415 $comment_id = $this->factory->comment->create(2415 $comment_id = self::factory()->comment->create( 2416 2416 array( 2417 2417 'comment_approved' => 0, … … 2440 2440 wp_set_current_user( self::$admin_id ); 2441 2441 2442 $comment_id = $this->factory->comment->create(2442 $comment_id = self::factory()->comment->create( 2443 2443 array( 2444 2444 'comment_approved' => 0, … … 2721 2721 2722 2722 public function test_update_comment_private_post_invalid_permission() { 2723 $private_comment_id = $this->factory->comment->create(2723 $private_comment_id = self::factory()->comment->create( 2724 2724 array( 2725 2725 'comment_approved' => 1, … … 2746 2746 wp_set_current_user( self::$admin_id ); 2747 2747 2748 $comment_id_1 = $this->factory->comment->create(2748 $comment_id_1 = self::factory()->comment->create( 2749 2749 array( 2750 2750 'comment_approved' => 1, … … 2754 2754 ); 2755 2755 2756 $child_comment = $this->factory->comment->create(2756 $child_comment = self::factory()->comment->create( 2757 2757 array( 2758 2758 'comment_approved' => 1, … … 3048 3048 wp_set_current_user( self::$admin_id ); 3049 3049 3050 $comment_id = $this->factory->comment->create(3050 $comment_id = self::factory()->comment->create( 3051 3051 array( 3052 3052 'comment_approved' => 1, … … 3068 3068 wp_set_current_user( self::$admin_id ); 3069 3069 3070 $comment_id = $this->factory->comment->create(3070 $comment_id = self::factory()->comment->create( 3071 3071 array( 3072 3072 'comment_approved' => 1, … … 3089 3089 wp_set_current_user( self::$admin_id ); 3090 3090 3091 $comment_id = $this->factory->comment->create(3091 $comment_id = self::factory()->comment->create( 3092 3092 array( 3093 3093 'comment_approved' => 1, … … 3124 3124 wp_set_current_user( self::$admin_id ); 3125 3125 3126 $comment_id_1 = $this->factory->comment->create(3126 $comment_id_1 = self::factory()->comment->create( 3127 3127 array( 3128 3128 'comment_approved' => 1, … … 3132 3132 ); 3133 3133 3134 $child_comment = $this->factory->comment->create(3134 $child_comment = self::factory()->comment->create( 3135 3135 array( 3136 3136 'comment_approved' => 1, -
trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php
r54058 r54090 52 52 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 53 53 // Single. 54 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );54 $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 55 55 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id ); 56 56 $response = rest_get_server()->dispatch( $request ); … … 95 95 96 96 public function test_get_items() { 97 $id1 = $this->factory->post->create(98 array( 99 'post_status' => 'publish', 100 'post_type' => 'page', 101 ) 102 ); 103 $id2 = $this->factory->post->create(97 $id1 = self::factory()->post->create( 98 array( 99 'post_status' => 'publish', 100 'post_type' => 'page', 101 ) 102 ); 103 $id2 = self::factory()->post->create( 104 104 array( 105 105 'post_status' => 'draft', … … 115 115 116 116 public function test_get_items_parent_query() { 117 $id1 = $this->factory->post->create(118 array( 119 'post_status' => 'publish', 120 'post_type' => 'page', 121 ) 122 ); 123 $id2 = $this->factory->post->create(117 $id1 = self::factory()->post->create( 118 array( 119 'post_status' => 'publish', 120 'post_type' => 'page', 121 ) 122 ); 123 $id2 = self::factory()->post->create( 124 124 array( 125 125 'post_status' => 'publish', … … 149 149 150 150 public function test_get_items_parents_query() { 151 $id1 = $this->factory->post->create(152 array( 153 'post_status' => 'publish', 154 'post_type' => 'page', 155 ) 156 ); 157 $id2 = $this->factory->post->create(151 $id1 = self::factory()->post->create( 152 array( 153 'post_status' => 'publish', 154 'post_type' => 'page', 155 ) 156 ); 157 $id2 = self::factory()->post->create( 158 158 array( 159 159 'post_status' => 'publish', … … 162 162 ) 163 163 ); 164 $id3 = $this->factory->post->create(165 array( 166 'post_status' => 'publish', 167 'post_type' => 'page', 168 ) 169 ); 170 $id4 = $this->factory->post->create(164 $id3 = self::factory()->post->create( 165 array( 166 'post_status' => 'publish', 167 'post_type' => 'page', 168 ) 169 ); 170 $id4 = self::factory()->post->create( 171 171 array( 172 172 'post_status' => 'publish', … … 191 191 192 192 public function test_get_items_parent_exclude_query() { 193 $id1 = $this->factory->post->create(194 array( 195 'post_status' => 'publish', 196 'post_type' => 'page', 197 ) 198 ); 199 $this->factory->post->create(193 $id1 = self::factory()->post->create( 194 array( 195 'post_status' => 'publish', 196 'post_type' => 'page', 197 ) 198 ); 199 self::factory()->post->create( 200 200 array( 201 201 'post_status' => 'publish', … … 225 225 226 226 public function test_get_items_menu_order_query() { 227 $id1 = $this->factory->post->create(228 array( 229 'post_status' => 'publish', 230 'post_type' => 'page', 231 ) 232 ); 233 $id2 = $this->factory->post->create(227 $id1 = self::factory()->post->create( 228 array( 229 'post_status' => 'publish', 230 'post_type' => 'page', 231 ) 232 ); 233 $id2 = self::factory()->post->create( 234 234 array( 235 235 'post_status' => 'publish', … … 238 238 ) 239 239 ); 240 $id3 = $this->factory->post->create(240 $id3 = self::factory()->post->create( 241 241 array( 242 242 'post_status' => 'publish', … … 245 245 ) 246 246 ); 247 $id4 = $this->factory->post->create(247 $id4 = self::factory()->post->create( 248 248 array( 249 249 'post_status' => 'publish', … … 303 303 // Private query vars inaccessible to unauthorized users. 304 304 wp_set_current_user( 0 ); 305 $page_id = $this->factory->post->create(306 array( 307 'post_status' => 'publish', 308 'post_type' => 'page', 309 ) 310 ); 311 $draft_id = $this->factory->post->create(305 $page_id = self::factory()->post->create( 306 array( 307 'post_status' => 'publish', 308 'post_type' => 'page', 309 ) 310 ); 311 $draft_id = self::factory()->post->create( 312 312 array( 313 313 'post_status' => 'draft', … … 337 337 338 338 public function test_get_items_valid_date() { 339 $post1 = $this->factory->post->create(339 $post1 = self::factory()->post->create( 340 340 array( 341 341 'post_date' => '2016-01-15T00:00:00Z', … … 343 343 ) 344 344 ); 345 $post2 = $this->factory->post->create(345 $post2 = self::factory()->post->create( 346 346 array( 347 347 'post_date' => '2016-01-16T00:00:00Z', … … 349 349 ) 350 350 ); 351 $post3 = $this->factory->post->create(351 $post3 = self::factory()->post->create( 352 352 array( 353 353 'post_date' => '2016-01-17T00:00:00Z', … … 379 379 */ 380 380 public function test_get_items_valid_modified_date() { 381 $post1 = $this->factory->post->create(381 $post1 = self::factory()->post->create( 382 382 array( 383 383 'post_date' => '2016-01-01 00:00:00', … … 385 385 ) 386 386 ); 387 $post2 = $this->factory->post->create(387 $post2 = self::factory()->post->create( 388 388 array( 389 389 'post_date' => '2016-01-02 00:00:00', … … 391 391 ) 392 392 ); 393 $post3 = $this->factory->post->create(393 $post3 = self::factory()->post->create( 394 394 array( 395 395 'post_date' => '2016-01-03 00:00:00', … … 417 417 418 418 public function test_get_item_invalid_post_type() { 419 $post_id = $this->factory->post->create();419 $post_id = self::factory()->post->create(); 420 420 $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); 421 421 $response = rest_get_server()->dispatch( $request ); … … 449 449 450 450 public function test_create_page_with_parent() { 451 $page_id = $this->factory->post->create(451 $page_id = self::factory()->post->create( 452 452 array( 453 453 'type' => 'page', … … 499 499 500 500 public function test_delete_item() { 501 $page_id = $this->factory->post->create(501 $page_id = self::factory()->post->create( 502 502 array( 503 503 'post_type' => 'page', … … 526 526 public function test_prepare_item_limit_fields() { 527 527 wp_set_current_user( self::$editor_id ); 528 $page_id = $this->factory->post->create(528 $page_id = self::factory()->post->create( 529 529 array( 530 530 'post_status' => 'publish', … … 548 548 549 549 public function test_get_pages_params() { 550 $this->factory->post->create_many(550 self::factory()->post->create_many( 551 551 8, 552 552 array( … … 579 579 public function test_update_page_menu_order() { 580 580 581 $page_id = $this->factory->post->create(581 $page_id = self::factory()->post->create( 582 582 array( 583 583 'post_type' => 'page', … … 602 602 public function test_update_page_menu_order_to_zero() { 603 603 604 $page_id = $this->factory->post->create(604 $page_id = self::factory()->post->create( 605 605 array( 606 606 'post_type' => 'page', … … 625 625 626 626 public function test_update_page_parent_non_zero() { 627 $page_id1 = $this->factory->post->create(628 array( 629 'post_type' => 'page', 630 ) 631 ); 632 $page_id2 = $this->factory->post->create(627 $page_id1 = self::factory()->post->create( 628 array( 629 'post_type' => 'page', 630 ) 631 ); 632 $page_id2 = self::factory()->post->create( 633 633 array( 634 634 'post_type' => 'page', … … 648 648 649 649 public function test_update_page_parent_zero() { 650 $page_id1 = $this->factory->post->create(651 array( 652 'post_type' => 'page', 653 ) 654 ); 655 $page_id2 = $this->factory->post->create(650 $page_id1 = self::factory()->post->create( 651 array( 652 'post_type' => 'page', 653 ) 654 ); 655 $page_id2 = self::factory()->post->create( 656 656 array( 657 657 'post_type' => 'page', … … 672 672 673 673 public function test_get_page_with_password() { 674 $page_id = $this->factory->post->create(674 $page_id = self::factory()->post->create( 675 675 array( 676 676 'post_type' => 'page', … … 690 690 691 691 public function test_get_page_with_password_using_password() { 692 $page_id = $this->factory->post->create(692 $page_id = self::factory()->post->create( 693 693 array( 694 694 'post_type' => 'page', … … 712 712 713 713 public function test_get_page_with_password_using_incorrect_password() { 714 $page_id = $this->factory->post->create(714 $page_id = self::factory()->post->create( 715 715 array( 716 716 'post_type' => 'page', … … 728 728 729 729 public function test_get_page_with_password_without_permission() { 730 $page_id = $this->factory->post->create(730 $page_id = self::factory()->post->create( 731 731 array( 732 732 'post_type' => 'page', -
trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
r51657 r54090 254 254 protected function grant_write_permission() { 255 255 // Ensure we have write permission. 256 $user = $this->factory->user->create(256 $user = self::factory()->user->create( 257 257 array( 258 258 'role' => 'editor', -
trunk/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php
r51367 r54090 44 44 45 45 public function test_get_items_logged_in() { 46 $user_id = $this->factory->user->create( array( 'role' => 'author' ) );46 $user_id = self::factory()->user->create( array( 'role' => 'author' ) ); 47 47 wp_set_current_user( $user_id ); 48 48 … … 73 73 74 74 public function test_get_item() { 75 $user_id = $this->factory->user->create( array( 'role' => 'author' ) );75 $user_id = self::factory()->user->create( array( 'role' => 'author' ) ); 76 76 wp_set_current_user( $user_id ); 77 77 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' ); … … 95 95 96 96 public function test_get_item_invalid_internal() { 97 $user_id = $this->factory->user->create();97 $user_id = self::factory()->user->create(); 98 98 wp_set_current_user( $user_id ); 99 99 -
trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php
r51962 r54090 95 95 96 96 public function test_get_item_edit_context() { 97 $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );97 $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 98 98 wp_set_current_user( $editor_id ); 99 99 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r54088 r54090 274 274 275 275 public function test_get_items_author_query() { 276 $this->factory->post->create( array( 'post_author' => self::$editor_id ) );277 $this->factory->post->create( array( 'post_author' => self::$author_id ) );276 self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); 277 self::factory()->post->create( array( 'post_author' => self::$author_id ) ); 278 278 279 279 $total_posts = self::$total_posts + 2; … … 306 306 307 307 public function test_get_items_author_exclude_query() { 308 $this->factory->post->create( array( 'post_author' => self::$editor_id ) );309 $this->factory->post->create( array( 'post_author' => self::$author_id ) );308 self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); 309 self::factory()->post->create( array( 'post_author' => self::$author_id ) ); 310 310 311 311 $total_posts = self::$total_posts + 2; … … 348 348 349 349 public function test_get_items_include_query() { 350 $id1 = $this->factory->post->create(350 $id1 = self::factory()->post->create( 351 351 array( 352 352 'post_status' => 'publish', … … 354 354 ) 355 355 ); 356 $id2 = $this->factory->post->create(356 $id2 = self::factory()->post->create( 357 357 array( 358 358 'post_status' => 'publish', … … 387 387 388 388 public function test_get_items_orderby_author_query() { 389 $id2 = $this->factory->post->create(389 $id2 = self::factory()->post->create( 390 390 array( 391 391 'post_status' => 'publish', … … 393 393 ) 394 394 ); 395 $id3 = $this->factory->post->create(395 $id3 = self::factory()->post->create( 396 396 array( 397 397 'post_status' => 'publish', … … 399 399 ) 400 400 ); 401 $id1 = $this->factory->post->create(401 $id1 = self::factory()->post->create( 402 402 array( 403 403 'post_status' => 'publish', … … 422 422 423 423 public function test_get_items_orderby_modified_query() { 424 $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) );425 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );426 $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );424 $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 425 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 426 $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 427 427 428 428 $this->update_post_modified( $id1, '2016-04-20 4:26:20' ); … … 446 446 447 447 public function test_get_items_orderby_parent_query() { 448 $id1 = $this->factory->post->create(448 $id1 = self::factory()->post->create( 449 449 array( 450 450 'post_status' => 'publish', … … 452 452 ) 453 453 ); 454 $id2 = $this->factory->post->create(454 $id2 = self::factory()->post->create( 455 455 array( 456 456 'post_status' => 'publish', … … 458 458 ) 459 459 ); 460 $id3 = $this->factory->post->create(460 $id3 = self::factory()->post->create( 461 461 array( 462 462 'post_status' => 'publish', … … 484 484 485 485 public function test_get_items_exclude_query() { 486 $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) );487 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );486 $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 487 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 488 488 489 489 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 514 514 515 515 public function test_get_items_search_query() { 516 $this->factory->post->create(516 self::factory()->post->create( 517 517 array( 518 518 'post_title' => 'Search Result', … … 536 536 537 537 public function test_get_items_slug_query() { 538 $this->factory->post->create(538 self::factory()->post->create( 539 539 array( 540 540 'post_title' => 'Apple', … … 542 542 ) 543 543 ); 544 $this->factory->post->create(544 self::factory()->post->create( 545 545 array( 546 546 'post_title' => 'Banana', … … 559 559 560 560 public function test_get_items_multiple_slugs_array_query() { 561 $this->factory->post->create(561 self::factory()->post->create( 562 562 array( 563 563 'post_title' => 'Apple', … … 565 565 ) 566 566 ); 567 $this->factory->post->create(567 self::factory()->post->create( 568 568 array( 569 569 'post_title' => 'Banana', … … 571 571 ) 572 572 ); 573 $this->factory->post->create(573 self::factory()->post->create( 574 574 array( 575 575 'post_title' => 'Peach', … … 593 593 594 594 public function test_get_items_multiple_slugs_string_query() { 595 $this->factory->post->create(595 self::factory()->post->create( 596 596 array( 597 597 'post_title' => 'Apple', … … 599 599 ) 600 600 ); 601 $this->factory->post->create(601 self::factory()->post->create( 602 602 array( 603 603 'post_title' => 'Banana', … … 605 605 ) 606 606 ); 607 $this->factory->post->create(607 self::factory()->post->create( 608 608 array( 609 609 'post_title' => 'Peach', … … 629 629 wp_set_current_user( 0 ); 630 630 631 $this->factory->post->create( array( 'post_status' => 'draft' ) );631 self::factory()->post->create( array( 'post_status' => 'draft' ) ); 632 632 633 633 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 655 655 wp_set_current_user( self::$editor_id ); 656 656 657 $this->factory->post->create( array( 'post_status' => 'draft' ) );658 $this->factory->post->create( array( 'post_status' => 'private' ) );659 $this->factory->post->create( array( 'post_status' => 'publish' ) );657 self::factory()->post->create( array( 'post_status' => 'draft' ) ); 658 self::factory()->post->create( array( 'post_status' => 'private' ) ); 659 self::factory()->post->create( array( 'post_status' => 'publish' ) ); 660 660 661 661 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 678 678 wp_set_current_user( self::$editor_id ); 679 679 680 $this->factory->post->create( array( 'post_status' => 'draft' ) );681 $this->factory->post->create( array( 'post_status' => 'pending' ) );682 $this->factory->post->create( array( 'post_status' => 'publish' ) );680 self::factory()->post->create( array( 'post_status' => 'draft' ) ); 681 self::factory()->post->create( array( 'post_status' => 'pending' ) ); 682 self::factory()->post->create( array( 'post_status' => 'publish' ) ); 683 683 684 684 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 710 710 */ 711 711 public function test_get_items_multiple_statuses_custom_role_one_invalid_query() { 712 $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );712 $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); 713 713 714 714 wp_set_current_user( self::$private_reader_id ); … … 731 731 732 732 public function test_get_items_status_without_permissions() { 733 $draft_id = $this->factory->post->create(733 $draft_id = self::factory()->post->create( 734 734 array( 735 735 'post_status' => 'draft', … … 751 751 752 752 public function test_get_items_order_and_orderby() { 753 $this->factory->post->create(753 self::factory()->post->create( 754 754 array( 755 755 'post_title' => 'Apple Pie', … … 757 757 ) 758 758 ); 759 $this->factory->post->create(759 self::factory()->post->create( 760 760 array( 761 761 'post_title' => 'Apple Sauce', … … 763 763 ) 764 764 ); 765 $this->factory->post->create(765 self::factory()->post->create( 766 766 array( 767 767 'post_title' => 'Apple Cobbler', … … 769 769 ) 770 770 ); 771 $this->factory->post->create(771 self::factory()->post->create( 772 772 array( 773 773 'post_title' => 'Apple Coffee Cake', … … 806 806 807 807 public function test_get_items_with_orderby_include_without_include_param() { 808 $this->factory->post->create( array( 'post_status' => 'publish' ) );808 self::factory()->post->create( array( 'post_status' => 'publish' ) ); 809 809 810 810 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 817 817 818 818 public function test_get_items_with_orderby_id() { 819 $id1 = $this->factory->post->create(819 $id1 = self::factory()->post->create( 820 820 array( 821 821 'post_status' => 'publish', … … 823 823 ) 824 824 ); 825 $id2 = $this->factory->post->create(825 $id2 = self::factory()->post->create( 826 826 array( 827 827 'post_status' => 'publish', … … 829 829 ) 830 830 ); 831 $id3 = $this->factory->post->create(831 $id3 = self::factory()->post->create( 832 832 array( 833 833 'post_status' => 'publish', … … 851 851 852 852 public function test_get_items_with_orderby_slug() { 853 $id1 = $this->factory->post->create(853 $id1 = self::factory()->post->create( 854 854 array( 855 855 'post_title' => 'ABC', … … 858 858 ) 859 859 ); 860 $id2 = $this->factory->post->create(860 $id2 = self::factory()->post->create( 861 861 array( 862 862 'post_title' => 'XYZ', … … 882 882 $slugs = array( 'burrito', 'taco', 'chalupa' ); 883 883 foreach ( $slugs as $slug ) { 884 $this->factory->post->create(884 self::factory()->post->create( 885 885 array( 886 886 'post_title' => $slug, … … 904 904 905 905 public function test_get_items_with_orderby_relevance() { 906 $id1 = $this->factory->post->create(906 $id1 = self::factory()->post->create( 907 907 array( 908 908 'post_title' => 'Title is more relevant', … … 911 911 ) 912 912 ); 913 $id2 = $this->factory->post->create(913 $id2 = self::factory()->post->create( 914 914 array( 915 915 'post_title' => 'Title is', … … 932 932 933 933 public function test_get_items_with_orderby_relevance_two_terms() { 934 $id1 = $this->factory->post->create(934 $id1 = self::factory()->post->create( 935 935 array( 936 936 'post_title' => 'Title is more relevant', … … 939 939 ) 940 940 ); 941 $id2 = $this->factory->post->create(941 $id2 = self::factory()->post->create( 942 942 array( 943 943 'post_title' => 'Title is', … … 1006 1006 public function test_get_items_tags_exclude_query() { 1007 1007 $id1 = self::$post_id; 1008 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1009 $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1010 $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1008 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1009 $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1010 $id4 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1011 1011 $tag = wp_insert_term( 'My Tag', 'post_tag' ); 1012 1012 … … 1029 1029 public function test_get_items_tags_and_categories_query() { 1030 1030 $id1 = self::$post_id; 1031 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1031 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1032 1032 $tag = wp_insert_term( 'My Tag', 'post_tag' ); 1033 1033 $category = wp_insert_term( 'My Category', 'category' ); … … 1054 1054 public function test_get_items_tags_or_categories_query() { 1055 1055 $id1 = self::$post_id; 1056 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1056 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1057 1057 $tag = wp_insert_term( 'My Tag', 'post_tag' ); 1058 1058 $category = wp_insert_term( 'My Category', 'category' ); … … 1076 1076 public function test_get_items_tags_and_categories_exclude_query() { 1077 1077 $id1 = self::$post_id; 1078 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1078 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1079 1079 $tag = wp_insert_term( 'My Tag', 'post_tag' ); 1080 1080 $category = wp_insert_term( 'My Category', 'category' ); … … 1103 1103 public function test_get_items_tags_or_categories_exclude_query() { 1104 1104 $id1 = end( self::$post_ids ); 1105 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1106 $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1107 $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1105 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1106 $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1107 $id4 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1108 1108 $tag = wp_insert_term( 'My Tag', 'post_tag' ); 1109 1109 $category = wp_insert_term( 'My Category', 'category' ); … … 1367 1367 public function test_get_items_sticky() { 1368 1368 $id1 = self::$post_id; 1369 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1369 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1370 1370 1371 1371 update_option( 'sticky_posts', array( $id2 ) ); … … 1388 1388 public function test_get_items_sticky_with_include() { 1389 1389 $id1 = self::$post_id; 1390 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1390 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1391 1391 1392 1392 update_option( 'sticky_posts', array( $id2 ) ); … … 1456 1456 public function test_get_items_not_sticky() { 1457 1457 $id1 = end( self::$post_ids ); 1458 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1458 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1459 1459 1460 1460 $total_posts = self::$total_posts + 1; … … 1478 1478 public function test_get_items_not_sticky_with_exclude() { 1479 1479 $id1 = end( self::$post_ids ); 1480 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1481 $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1480 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1481 $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1482 1482 1483 1483 $total_posts = self::$total_posts + 2; … … 1504 1504 public function test_get_items_not_sticky_with_exclude_no_sticky_posts() { 1505 1505 $id1 = self::$post_id; 1506 $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1507 $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );1506 $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1507 $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 1508 1508 1509 1509 $total_posts = self::$total_posts + 2; … … 1575 1575 $parent_ids = array( $parent_id1, $parent_id2 ); 1576 1576 $attachment_ids = array(); 1577 $attachment_ids[] = $this->factory->attachment->create_object(1577 $attachment_ids[] = self::factory()->attachment->create_object( 1578 1578 DIR_TESTDATA . '/images/canola.jpg', 1579 1579 $parent_id1, … … 1584 1584 ); 1585 1585 1586 $attachment_ids[] = $this->factory->attachment->create_object(1586 $attachment_ids[] = self::factory()->attachment->create_object( 1587 1587 DIR_TESTDATA . '/images/canola.jpg', 1588 1588 $parent_id2, … … 1629 1629 1630 1630 // 3rd page. 1631 $this->factory->post->create();1631 self::factory()->post->create(); 1632 1632 $total_posts++; 1633 1633 $total_pages++; … … 1708 1708 1709 1709 public function test_get_items_status_draft_permissions() { 1710 $draft_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );1710 $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 1711 1711 1712 1712 // Drafts status query var inaccessible to unauthorized users. … … 1738 1738 */ 1739 1739 public function test_get_items_status_private_permissions() { 1740 $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );1740 $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); 1741 1741 1742 1742 wp_set_current_user( 0 ); … … 1793 1793 1794 1794 public function test_get_items_valid_date() { 1795 $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) );1796 $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) );1797 $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) );1795 $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) ); 1796 $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) ); 1797 $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) ); 1798 1798 1799 1799 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 1821 1821 */ 1822 1822 public function test_get_items_valid_modified_date() { 1823 $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) );1824 $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) );1825 $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) );1823 $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) ); 1824 $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) ); 1825 $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) ); 1826 1826 $this->update_post_modified( $post1, '2016-01-15 00:00:00' ); 1827 1827 $this->update_post_modified( $post2, '2016-01-16 00:00:00' ); … … 1941 1941 1942 1942 public function test_get_post_draft_status_not_authenticated() { 1943 $draft_id = $this->factory->post->create(1943 $draft_id = self::factory()->post->create( 1944 1944 array( 1945 1945 'post_status' => 'draft', … … 1957 1957 public function test_get_post_draft_edit_context() { 1958 1958 $post_content = 'Hello World!'; 1959 $this->factory->post->create(1959 self::factory()->post->create( 1960 1960 array( 1961 1961 'post_title' => 'Hola', … … 1966 1966 ) 1967 1967 ); 1968 $draft_id = $this->factory->post->create(1968 $draft_id = self::factory()->post->create( 1969 1969 array( 1970 1970 'post_status' => 'draft', … … 2032 2032 2033 2033 public function test_get_post_with_password() { 2034 $post_id = $this->factory->post->create(2034 $post_id = self::factory()->post->create( 2035 2035 array( 2036 2036 'post_password' => '$inthebananastand', … … 2051 2051 2052 2052 public function test_get_post_with_password_using_password() { 2053 $post_id = $this->factory->post->create(2053 $post_id = self::factory()->post->create( 2054 2054 array( 2055 2055 'post_password' => '$inthebananastand', … … 2075 2075 2076 2076 public function test_get_post_with_password_using_incorrect_password() { 2077 $post_id = $this->factory->post->create(2077 $post_id = self::factory()->post->create( 2078 2078 array( 2079 2079 'post_password' => '$inthebananastand', … … 2091 2091 2092 2092 public function test_get_post_with_password_without_permission() { 2093 $post_id = $this->factory->post->create(2093 $post_id = self::factory()->post->create( 2094 2094 array( 2095 2095 'post_password' => '$inthebananastand', … … 2115 2115 */ 2116 2116 public function test_get_post_should_not_have_block_version_when_context_view() { 2117 $post_id = $this->factory->post->create(2117 $post_id = self::factory()->post->create( 2118 2118 array( 2119 2119 'post_content' => '<!-- wp:core/separator -->', … … 2135 2135 wp_set_current_user( self::$editor_id ); 2136 2136 2137 $post_id = $this->factory->post->create(2137 $post_id = self::factory()->post->create( 2138 2138 array( 2139 2139 'post_content' => '<!-- wp:core/separator -->', … … 2156 2156 wp_set_current_user( self::$editor_id ); 2157 2157 2158 $post_id = $this->factory->post->create(2158 $post_id = self::factory()->post->create( 2159 2159 array( 2160 2160 'post_content' => '<hr />', … … 2784 2784 2785 2785 $file = DIR_TESTDATA . '/images/canola.jpg'; 2786 $attachment_id = $this->factory->attachment->create_object(2786 $attachment_id = self::factory()->attachment->create_object( 2787 2787 $file, 2788 2788 0, … … 3188 3188 public function test_rest_update_post_with_empty_date() { 3189 3189 // Create a new test post. 3190 $post_id = $this->factory->post->create();3190 $post_id = self::factory()->post->create(); 3191 3191 3192 3192 wp_set_current_user( self::$editor_id ); … … 3437 3437 update_option( 'timezone_string', $params['timezone_string'] ); 3438 3438 3439 $post_id = $this->factory->post->create( array( 'post_status' => $status ) );3439 $post_id = self::factory()->post->create( array( 'post_status' => $status ) ); 3440 3440 3441 3441 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) ); … … 3502 3502 // Need to set dates using wpdb directly because `wp_update_post` and 3503 3503 // `wp_insert_post` have additional validation on dates. 3504 $post_id = $this->factory->post->create();3504 $post_id = self::factory()->post->create(); 3505 3505 $wpdb->update( 3506 3506 $wpdb->posts, … … 4172 4172 4173 4173 public function test_delete_item() { 4174 $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );4174 $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) ); 4175 4175 4176 4176 wp_set_current_user( self::$editor_id ); … … 4187 4187 4188 4188 public function test_delete_item_skip_trash() { 4189 $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );4189 $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) ); 4190 4190 4191 4191 wp_set_current_user( self::$editor_id ); … … 4202 4202 4203 4203 public function test_delete_item_already_trashed() { 4204 $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );4204 $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) ); 4205 4205 4206 4206 wp_set_current_user( self::$editor_id ); … … 4223 4223 4224 4224 public function test_delete_post_invalid_post_type() { 4225 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );4225 $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 4226 4226 4227 4227 wp_set_current_user( self::$editor_id ); … … 4466 4466 wp_set_current_user( 1 ); 4467 4467 4468 $post_id = $this->factory->post->create();4468 $post_id = self::factory()->post->create(); 4469 4469 4470 4470 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id ); … … 4511 4511 ) 4512 4512 ); 4513 $post_id = $this->factory->post->create();4513 $post_id = self::factory()->post->create(); 4514 4514 4515 4515 // 'my_custom_int' should appear because ?_fields= isn't set. … … 4932 4932 wp_set_current_user( self::$editor_id ); 4933 4933 4934 $post_id = $this->factory->post->create(4934 $post_id = self::factory()->post->create( 4935 4935 array( 4936 4936 'post_title' => 'Permalink Template', … … 4956 4956 wp_set_current_user( self::$editor_id ); 4957 4957 4958 $post_id = $this->factory->post->create(4958 $post_id = self::factory()->post->create( 4959 4959 array( 4960 4960 'post_title' => 'Permalink Template', -
trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php
r54043 r54090 206 206 // is not desirable. 207 207 208 $administrator_id = $this->factory->user->create(208 $administrator_id = self::factory()->user->create( 209 209 array( 210 210 'role' => 'administrator', … … 216 216 wp_set_current_user( $administrator_id ); 217 217 218 $post_id = $this->factory->post->create(218 $post_id = self::factory()->post->create( 219 219 array( 220 220 'post_name' => 'restapi-client-fixture-post', … … 244 244 ); 245 245 246 $page_id = $this->factory->post->create(246 $page_id = self::factory()->post->create( 247 247 array( 248 248 'post_type' => 'page', … … 274 274 ); 275 275 276 $tag_id = $this->factory->tag->create(276 $tag_id = self::factory()->tag->create( 277 277 array( 278 278 'name' => 'REST API Client Fixture: Tag', … … 282 282 ); 283 283 284 $media_id = $this->factory->attachment->create_object(284 $media_id = self::factory()->attachment->create_object( 285 285 get_temp_dir() . 'canola.jpg', 286 286 0, … … 296 296 ); 297 297 298 $comment_id = $this->factory->comment->create(298 $comment_id = self::factory()->comment->create( 299 299 array( 300 300 'comment_approved' => 1, -
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r53909 r54090 140 140 $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 141 141 // Single. 142 $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) );142 $tag1 = self::factory()->tag->create( array( 'name' => 'Season 5' ) ); 143 143 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 ); 144 144 $response = rest_get_server()->dispatch( $request ); … … 175 175 176 176 public function test_get_items() { 177 $this->factory->tag->create();177 self::factory()->tag->create(); 178 178 179 179 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 193 193 194 194 public function test_get_items_hide_empty_arg() { 195 $post_id = $this->factory->post->create();196 $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) );197 $tag2 = $this->factory->tag->create( array( 'name' => 'The Be Sharps' ) );195 $post_id = self::factory()->post->create(); 196 $tag1 = self::factory()->tag->create( array( 'name' => 'Season 5' ) ); 197 $tag2 = self::factory()->tag->create( array( 'name' => 'The Be Sharps' ) ); 198 198 199 199 wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' ); … … 214 214 215 215 public function test_get_items_include_query() { 216 $id1 = $this->factory->tag->create();217 $id2 = $this->factory->tag->create();216 $id1 = self::factory()->tag->create(); 217 $id2 = self::factory()->tag->create(); 218 218 219 219 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 240 240 241 241 public function test_get_items_exclude_query() { 242 $id1 = $this->factory->tag->create();243 $id2 = $this->factory->tag->create();242 $id1 = self::factory()->tag->create(); 243 $id2 = self::factory()->tag->create(); 244 244 245 245 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 289 289 290 290 public function test_get_items_orderby_args() { 291 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );292 $tag2 = $this->factory->tag->create( array( 'name' => 'Zucchini' ) );291 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 292 $tag2 = self::factory()->tag->create( array( 'name' => 'Zucchini' ) ); 293 293 294 294 /* … … 325 325 326 326 public function test_get_items_orderby_id() { 327 $tag0 = $this->factory->tag->create( array( 'name' => 'Cantaloupe' ) );328 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );329 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );327 $tag0 = self::factory()->tag->create( array( 'name' => 'Cantaloupe' ) ); 328 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 329 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 330 330 331 331 // Defaults to 'orderby' => 'name', 'order' => 'asc'. … … 361 361 362 362 public function test_get_items_orderby_slugs() { 363 $this->factory->tag->create( array( 'name' => 'Burrito' ) );364 $this->factory->tag->create( array( 'name' => 'Taco' ) );365 $this->factory->tag->create( array( 'name' => 'Chalupa' ) );363 self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 364 self::factory()->tag->create( array( 'name' => 'Taco' ) ); 365 self::factory()->tag->create( array( 'name' => 'Chalupa' ) ); 366 366 367 367 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 377 377 378 378 public function test_get_items_post_args() { 379 $post_id = $this->factory->post->create();380 $tag1 = $this->factory->tag->create( array( 'name' => 'DC' ) );381 $tag2 = $this->factory->tag->create( array( 'name' => 'Marvel' ) );382 $this->factory->tag->create( array( 'name' => 'Dark Horse' ) );379 $post_id = self::factory()->post->create(); 380 $tag1 = self::factory()->tag->create( array( 'name' => 'DC' ) ); 381 $tag2 = self::factory()->tag->create( array( 'name' => 'Marvel' ) ); 382 self::factory()->tag->create( array( 'name' => 'Dark Horse' ) ); 383 383 384 384 wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' ); … … 401 401 402 402 public function test_get_terms_post_args_paging() { 403 $post_id = $this->factory->post->create();403 $post_id = self::factory()->post->create(); 404 404 405 405 wp_set_object_terms( $post_id, self::$tag_ids, 'post_tag' ); … … 438 438 439 439 public function test_get_items_post_empty() { 440 $post_id = $this->factory->post->create();440 $post_id = self::factory()->post->create(); 441 441 442 442 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 453 453 $controller = new WP_REST_Terms_Controller( 'batman' ); 454 454 $controller->register_routes(); 455 $term1 = $this->factory->term->create(455 $term1 = self::factory()->term->create( 456 456 array( 457 457 'name' => 'Cape', … … 459 459 ) 460 460 ); 461 $term2 = $this->factory->term->create(461 $term2 = self::factory()->term->create( 462 462 array( 463 463 'name' => 'Mask', … … 465 465 ) 466 466 ); 467 $this->factory->term->create(467 self::factory()->term->create( 468 468 array( 469 469 'name' => 'Car', … … 471 471 ) 472 472 ); 473 $post_id = $this->factory->post->create();473 $post_id = self::factory()->post->create(); 474 474 475 475 wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); … … 486 486 487 487 public function test_get_items_search_args() { 488 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );489 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );488 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 489 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 490 490 491 491 /* … … 510 510 511 511 public function test_get_items_slug_arg() { 512 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );513 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );512 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 513 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 514 514 515 515 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 523 523 524 524 public function test_get_items_slug_array_arg() { 525 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );526 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );527 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );528 $this->factory->tag->create( array( 'name' => 'Pizza' ) );525 $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) ); 526 $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) ); 527 $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 528 self::factory()->tag->create( array( 'name' => 'Pizza' ) ); 529 529 530 530 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 546 546 547 547 public function test_get_items_slug_csv_arg() { 548 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );549 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );550 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );551 $this->factory->tag->create( array( 'name' => 'Pizza' ) );548 $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) ); 549 $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) ); 550 $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 551 self::factory()->tag->create( array( 'name' => 'Pizza' ) ); 552 552 553 553 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 563 563 public function test_get_terms_private_taxonomy() { 564 564 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 565 $term1 = $this->factory->term->create(565 $term1 = self::factory()->term->create( 566 566 array( 567 567 'name' => 'Cape', … … 569 569 ) 570 570 ); 571 $term2 = $this->factory->term->create(571 $term2 = self::factory()->term->create( 572 572 array( 573 573 'name' => 'Mask', … … 601 601 602 602 // 3rd page. 603 $this->factory->tag->create();603 self::factory()->tag->create(); 604 604 $total_tags++; 605 605 $total_pages++; … … 666 666 667 667 public function test_get_item() { 668 $id = $this->factory->tag->create();668 $id = self::factory()->tag->create(); 669 669 670 670 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 677 677 */ 678 678 public function test_get_item_meta() { 679 $id = $this->factory->tag->create();679 $id = self::factory()->tag->create(); 680 680 681 681 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 699 699 */ 700 700 public function test_get_item_meta_registered_for_different_taxonomy() { 701 $id = $this->factory->tag->create();701 $id = self::factory()->tag->create(); 702 702 703 703 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 717 717 718 718 public function test_get_item_invalid_permission_for_context() { 719 $id = $this->factory->tag->create();719 $id = self::factory()->tag->create(); 720 720 721 721 wp_set_current_user( 0 ); … … 729 729 public function test_get_term_private_taxonomy() { 730 730 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 731 $term1 = $this->factory->term->create(731 $term1 = self::factory()->term->create( 732 732 array( 733 733 'name' => 'Cape', … … 743 743 public function test_get_item_incorrect_taxonomy() { 744 744 register_taxonomy( 'robin', 'post' ); 745 $term1 = $this->factory->term->create(745 $term1 = self::factory()->term->create( 746 746 array( 747 747 'name' => 'Cape', … … 834 834 wp_set_current_user( self::$administrator ); 835 835 836 $existing_tag_id = $this->factory->tag->create( array( 'name' => 'My Not So Awesome Term' ) );836 $existing_tag_id = self::factory()->tag->create( array( 'name' => 'My Not So Awesome Term' ) ); 837 837 838 838 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); … … 859 859 ); 860 860 861 $term = get_term_by( 'id', $this->factory->tag->create( $orig_args ), 'post_tag' );861 $term = get_term_by( 'id', self::factory()->tag->create( $orig_args ), 'post_tag' ); 862 862 863 863 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 887 887 wp_set_current_user( self::$administrator ); 888 888 889 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );889 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 890 890 891 891 $request = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id ); … … 915 915 wp_set_current_user( self::$subscriber ); 916 916 917 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );917 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 918 918 919 919 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 929 929 wp_set_current_user( self::$subscriber ); 930 930 931 $term = $this->factory->tag->create_and_get();931 $term = self::factory()->tag->create_and_get(); 932 932 933 933 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 956 956 wp_set_current_user( self::$administrator ); 957 957 958 $term = $this->factory->tag->create_and_get();958 $term = self::factory()->tag->create_and_get(); 959 959 960 960 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 978 978 wp_set_current_user( self::$administrator ); 979 979 980 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );980 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 981 981 982 982 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 1105 1105 wp_set_current_user( self::$administrator ); 1106 1106 1107 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1107 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1108 1108 1109 1109 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1119 1119 wp_set_current_user( self::$administrator ); 1120 1120 1121 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1121 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1122 1122 1123 1123 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1141 1141 wp_set_current_user( self::$subscriber ); 1142 1142 1143 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1143 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1144 1144 1145 1145 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1154 1154 wp_set_current_user( self::$subscriber ); 1155 1155 1156 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1156 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1157 1157 1158 1158 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1182 1182 wp_set_current_user( self::$administrator ); 1183 1183 1184 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1184 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1185 1185 1186 1186 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1202 1202 1203 1203 public function test_prepare_item() { 1204 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1204 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1205 1205 1206 1206 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $term->term_id ); … … 1215 1215 $endpoint = new WP_REST_Terms_Controller( 'post_tag' ); 1216 1216 $request->set_param( '_fields', 'id,name' ); 1217 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1217 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1218 1218 $response = $endpoint->prepare_item_for_response( $term, $request ); 1219 1219 $this->assertSame( … … 1277 1277 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1278 1278 1279 $tag_id = $this->factory->tag->create();1279 $tag_id = self::factory()->tag->create(); 1280 1280 1281 1281 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $tag_id ); … … 1307 1307 wp_set_current_user( self::$administrator ); 1308 1308 1309 $tag_id = $this->factory->tag->create();1309 $tag_id = self::factory()->tag->create(); 1310 1310 1311 1311 // Check for error on update. … … 1331 1331 global $wpdb; 1332 1332 1333 $tags = $this->factory->tag->create_many( 2 );1334 $p = $this->factory->post->create();1333 $tags = self::factory()->tag->create_many( 2 ); 1334 $p = self::factory()->post->create(); 1335 1335 wp_set_object_terms( $p, $tags[0], 'post_tag' ); 1336 1336 -
trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
r52079 r54090 113 113 114 114 public function test_get_item_edit_context() { 115 $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );115 $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 116 116 wp_set_current_user( $editor_id ); 117 117 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/category' ); -
trunk/tests/phpunit/tests/rest-api/rest-term-meta-fields.php
r51571 r54090 201 201 protected function grant_write_permission() { 202 202 // Ensure we have write permission. 203 $user = $this->factory->user->create(203 $user = self::factory()->user->create( 204 204 array( 205 205 'role' => 'editor', -
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r53948 r54090 341 341 342 342 // 3rd page. 343 $this->factory->user->create();343 self::factory()->user->create(); 344 344 $total_users++; 345 345 $total_pages++; … … 433 433 wp_set_current_user( self::$user ); 434 434 435 $low_id = $this->factory->user->create( array( 'display_name' => 'AAAAA' ) );436 $mid_id = $this->factory->user->create( array( 'display_name' => 'NNNNN' ) );437 $high_id = $this->factory->user->create( array( 'display_name' => 'ZZZZ' ) );435 $low_id = self::factory()->user->create( array( 'display_name' => 'AAAAA' ) ); 436 $mid_id = self::factory()->user->create( array( 'display_name' => 'NNNNN' ) ); 437 $high_id = self::factory()->user->create( array( 'display_name' => 'ZZZZ' ) ); 438 438 439 439 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 457 457 wp_set_current_user( self::$user ); 458 458 459 $low_id = $this->factory->user->create( array( 'user_url' => 'http://a.com' ) );460 $high_id = $this->factory->user->create( array( 'user_url' => 'http://b.com' ) );459 $low_id = self::factory()->user->create( array( 'user_url' => 'http://a.com' ) ); 460 $high_id = self::factory()->user->create( array( 'user_url' => 'http://b.com' ) ); 461 461 462 462 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 482 482 wp_set_current_user( self::$user ); 483 483 484 $high_id = $this->factory->user->create( array( 'user_nicename' => 'blogin' ) );485 $low_id = $this->factory->user->create( array( 'user_nicename' => 'alogin' ) );484 $high_id = self::factory()->user->create( array( 'user_nicename' => 'blogin' ) ); 485 $low_id = self::factory()->user->create( array( 'user_nicename' => 'alogin' ) ); 486 486 487 487 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 507 507 wp_set_current_user( self::$user ); 508 508 509 $this->factory->user->create( array( 'user_nicename' => 'burrito' ) );510 $this->factory->user->create( array( 'user_nicename' => 'taco' ) );511 $this->factory->user->create( array( 'user_nicename' => 'chalupa' ) );509 self::factory()->user->create( array( 'user_nicename' => 'burrito' ) ); 510 self::factory()->user->create( array( 'user_nicename' => 'taco' ) ); 511 self::factory()->user->create( array( 'user_nicename' => 'chalupa' ) ); 512 512 513 513 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 525 525 wp_set_current_user( self::$user ); 526 526 527 $high_id = $this->factory->user->create( array( 'user_email' => 'bemail@gmail.com' ) );528 $low_id = $this->factory->user->create( array( 'user_email' => 'aemail@gmail.com' ) );527 $high_id = self::factory()->user->create( array( 'user_email' => 'bemail@gmail.com' ) ); 528 $low_id = self::factory()->user->create( array( 'user_email' => 'aemail@gmail.com' ) ); 529 529 530 530 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 605 605 wp_set_current_user( self::$user ); 606 606 607 $id1 = $this->factory->user->create();608 $id2 = $this->factory->user->create();607 $id1 = self::factory()->user->create(); 608 $id2 = self::factory()->user->create(); 609 609 610 610 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 641 641 wp_set_current_user( self::$user ); 642 642 643 $id1 = $this->factory->user->create();644 $id2 = $this->factory->user->create();643 $id1 = self::factory()->user->create(); 644 $id2 = self::factory()->user->create(); 645 645 646 646 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 673 673 $this->assertCount( 0, $response->get_data() ); 674 674 675 $yolo_id = $this->factory->user->create( array( 'display_name' => 'yololololo' ) );675 $yolo_id = self::factory()->user->create( array( 'display_name' => 'yololololo' ) ); 676 676 677 677 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 680 680 $this->assertCount( 1, $response->get_data() ); 681 681 // Default to wildcard search. 682 $adam_id = $this->factory->user->create(682 $adam_id = self::factory()->user->create( 683 683 array( 684 684 'role' => 'author', … … 698 698 wp_set_current_user( self::$user ); 699 699 700 $this->factory->user->create(700 self::factory()->user->create( 701 701 array( 702 702 'display_name' => 'foo', … … 704 704 ) 705 705 ); 706 $id2 = $this->factory->user->create(706 $id2 = self::factory()->user->create( 707 707 array( 708 708 'display_name' => 'Moo', … … 722 722 wp_set_current_user( self::$user ); 723 723 724 $id1 = $this->factory->user->create(724 $id1 = self::factory()->user->create( 725 725 array( 726 726 'display_name' => 'Taco', … … 728 728 ) 729 729 ); 730 $id2 = $this->factory->user->create(730 $id2 = self::factory()->user->create( 731 731 array( 732 732 'display_name' => 'Enchilada', … … 734 734 ) 735 735 ); 736 $id3 = $this->factory->user->create(736 $id3 = self::factory()->user->create( 737 737 array( 738 738 'display_name' => 'Burrito', … … 740 740 ) 741 741 ); 742 $this->factory->user->create(742 self::factory()->user->create( 743 743 array( 744 744 'display_name' => 'Hon Pizza', … … 768 768 wp_set_current_user( self::$user ); 769 769 770 $id1 = $this->factory->user->create(770 $id1 = self::factory()->user->create( 771 771 array( 772 772 'display_name' => 'Taco', … … 774 774 ) 775 775 ); 776 $id2 = $this->factory->user->create(776 $id2 = self::factory()->user->create( 777 777 array( 778 778 'display_name' => 'Enchilada', … … 780 780 ) 781 781 ); 782 $id3 = $this->factory->user->create(782 $id3 = self::factory()->user->create( 783 783 array( 784 784 'display_name' => 'Burrito', … … 786 786 ) 787 787 ); 788 $this->factory->user->create(788 self::factory()->user->create( 789 789 array( 790 790 'display_name' => 'Hon Pizza', … … 963 963 964 964 public function test_get_item() { 965 $user_id = $this->factory->user->create();965 $user_id = self::factory()->user->create(); 966 966 967 967 wp_set_current_user( self::$user ); … … 1030 1030 $this->allow_user_to_manage_multisite(); 1031 1031 1032 $lolz = $this->factory->user->create(1032 $lolz = self::factory()->user->create( 1033 1033 array( 1034 1034 'display_name' => 'lolz', … … 1115 1115 1116 1116 public function test_get_item_published_author_post() { 1117 $author_id = $this->factory->user->create(1117 $author_id = self::factory()->user->create( 1118 1118 array( 1119 1119 'role' => 'author', … … 1121 1121 ); 1122 1122 1123 $post_id = $this->factory->post->create(1123 $post_id = self::factory()->post->create( 1124 1124 array( 1125 1125 'post_author' => $author_id, … … 1135 1135 1136 1136 public function test_get_item_published_author_pages() { 1137 $author_id = $this->factory->user->create(1137 $author_id = self::factory()->user->create( 1138 1138 array( 1139 1139 'role' => 'author', … … 1147 1147 $this->assertSame( 401, $response->get_status() ); 1148 1148 1149 $post_id = $this->factory->post->create(1149 $post_id = self::factory()->post->create( 1150 1150 array( 1151 1151 'post_author' => $author_id, … … 1159 1159 1160 1160 public function test_get_user_with_edit_context() { 1161 $user_id = $this->factory->user->create();1161 $user_id = self::factory()->user->create(); 1162 1162 1163 1163 $this->allow_user_to_manage_multisite(); … … 1170 1170 1171 1171 public function test_get_item_published_author_wrong_context() { 1172 $author_id = $this->factory->user->create(1172 $author_id = self::factory()->user->create( 1173 1173 array( 1174 1174 'role' => 'author', … … 1176 1176 ); 1177 1177 1178 $post_id = $this->factory->post->create(1178 $post_id = self::factory()->post->create( 1179 1179 array( 1180 1180 'post_author' => $author_id, … … 1555 1555 1556 1556 public function test_update_item() { 1557 $user_id = $this->factory->user->create(1557 $user_id = self::factory()->user->create( 1558 1558 array( 1559 1559 'user_email' => 'test@example.com', … … 1621 1621 1622 1622 public function test_update_item_existing_email() { 1623 $user1 = $this->factory->user->create(1623 $user1 = self::factory()->user->create( 1624 1624 array( 1625 1625 'user_login' => 'test_json_user', … … 1627 1627 ) 1628 1628 ); 1629 $user2 = $this->factory->user->create(1629 $user2 = self::factory()->user->create( 1630 1630 array( 1631 1631 'user_login' => 'test_json_user2', … … 1685 1685 1686 1686 public function test_update_item_invalid_locale() { 1687 $user1 = $this->factory->user->create(1687 $user1 = self::factory()->user->create( 1688 1688 array( 1689 1689 'user_login' => 'test_json_user', … … 1704 1704 1705 1705 public function test_update_item_en_US_locale() { 1706 $user_id = $this->factory->user->create(1706 $user_id = self::factory()->user->create( 1707 1707 array( 1708 1708 'user_login' => 'test_json_user', … … 1728 1728 */ 1729 1729 public function test_update_item_empty_locale() { 1730 $user_id = $this->factory->user->create(1730 $user_id = self::factory()->user->create( 1731 1731 array( 1732 1732 'user_login' => 'test_json_user', … … 1752 1752 1753 1753 public function test_update_item_username_attempt() { 1754 $user1 = $this->factory->user->create(1754 $user1 = self::factory()->user->create( 1755 1755 array( 1756 1756 'user_login' => 'test_json_user', … … 1758 1758 ) 1759 1759 ); 1760 $user2 = $this->factory->user->create(1760 $user2 = self::factory()->user->create( 1761 1761 array( 1762 1762 'user_login' => 'test_json_user2', … … 1777 1777 1778 1778 public function test_update_item_existing_nicename() { 1779 $user1 = $this->factory->user->create(1779 $user1 = self::factory()->user->create( 1780 1780 array( 1781 1781 'user_login' => 'test_json_user', … … 1783 1783 ) 1784 1784 ); 1785 $user2 = $this->factory->user->create(1785 $user2 = self::factory()->user->create( 1786 1786 array( 1787 1787 'user_login' => 'test_json_user2', … … 1802 1802 1803 1803 public function test_json_update_user() { 1804 $user_id = $this->factory->user->create(1804 $user_id = self::factory()->user->create( 1805 1805 array( 1806 1806 'user_email' => 'testjson2@example.com', … … 1847 1847 1848 1848 public function test_update_user_role() { 1849 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1849 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 1850 1850 1851 1851 wp_set_current_user( self::$user ); … … 1868 1868 1869 1869 public function test_update_user_multiple_roles() { 1870 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1870 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 1871 1871 1872 1872 wp_set_current_user( self::$user ); … … 1914 1914 */ 1915 1915 public function test_update_user_role_invalid_privilege_deescalation() { 1916 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1916 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 1917 1917 1918 1918 wp_set_current_user( $user_id ); … … 1943 1943 */ 1944 1944 public function test_update_user_role_privilege_deescalation_multisite() { 1945 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1945 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 1946 1946 1947 1947 wp_set_current_user( $user_id ); … … 1957 1957 $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); 1958 1958 1959 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1959 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 1960 1960 1961 1961 wp_set_current_user( $user_id ); … … 2047 2047 */ 2048 2048 public function test_update_item_only_roles_as_editor() { 2049 $user_id = $this->factory->user->create(2049 $user_id = self::factory()->user->create( 2050 2050 array( 2051 2051 'role' => 'author', … … 2065 2065 */ 2066 2066 public function test_update_item_only_roles_as_site_administrator() { 2067 $user_id = $this->factory->user->create(2067 $user_id = self::factory()->user->create( 2068 2068 array( 2069 2069 'role' => 'author', … … 2086 2086 */ 2087 2087 public function test_update_item_including_roles_and_other_params() { 2088 $user_id = $this->factory->user->create(2088 $user_id = self::factory()->user->create( 2089 2089 array( 2090 2090 'role' => 'author', … … 2342 2342 2343 2343 public function test_delete_item() { 2344 $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );2344 $user_id = self::factory()->user->create( array( 'display_name' => 'Deleted User' ) ); 2345 2345 2346 2346 $this->allow_user_to_manage_multisite(); … … 2367 2367 2368 2368 public function test_delete_item_no_trash() { 2369 $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );2369 $user_id = self::factory()->user->create( array( 'display_name' => 'Deleted User' ) ); 2370 2370 2371 2371 $this->allow_user_to_manage_multisite(); … … 2397 2397 2398 2398 public function test_delete_current_item() { 2399 $user_id = $this->factory->user->create(2399 $user_id = self::factory()->user->create( 2400 2400 array( 2401 2401 'role' => 'administrator', … … 2426 2426 2427 2427 public function test_delete_current_item_no_trash() { 2428 $user_id = $this->factory->user->create(2428 $user_id = self::factory()->user->create( 2429 2429 array( 2430 2430 'role' => 'administrator', … … 2459 2459 2460 2460 public function test_delete_user_without_permission() { 2461 $user_id = $this->factory->user->create();2461 $user_id = self::factory()->user->create(); 2462 2462 2463 2463 $this->allow_user_to_manage_multisite(); … … 2497 2497 2498 2498 // Test with a new user, to avoid any complications. 2499 $user_id = $this->factory->user->create();2500 $reassign_id = $this->factory->user->create();2501 $test_post = $this->factory->post->create(2499 $user_id = self::factory()->user->create(); 2500 $reassign_id = self::factory()->user->create(); 2501 $test_post = self::factory()->post->create( 2502 2502 array( 2503 2503 'post_author' => $user_id, … … 2531 2531 2532 2532 public function test_delete_user_invalid_reassign_id() { 2533 $user_id = $this->factory->user->create();2533 $user_id = self::factory()->user->create(); 2534 2534 2535 2535 $this->allow_user_to_manage_multisite(); … … 2552 2552 2553 2553 public function test_delete_user_invalid_reassign_passed_as_string() { 2554 $user_id = $this->factory->user->create();2554 $user_id = self::factory()->user->create(); 2555 2555 2556 2556 $this->allow_user_to_manage_multisite(); … … 2567 2567 2568 2568 public function test_delete_user_reassign_passed_as_boolean_false_trashes_post() { 2569 $user_id = $this->factory->user->create();2570 2571 $this->allow_user_to_manage_multisite(); 2572 2573 wp_set_current_user( self::$user ); 2574 2575 $test_post = $this->factory->post->create(2569 $user_id = self::factory()->user->create(); 2570 2571 $this->allow_user_to_manage_multisite(); 2572 2573 wp_set_current_user( self::$user ); 2574 2575 $test_post = self::factory()->post->create( 2576 2576 array( 2577 2577 'post_author' => $user_id, … … 2595 2595 2596 2596 public function test_delete_user_reassign_passed_as_string_false_trashes_post() { 2597 $user_id = $this->factory->user->create();2598 2599 $this->allow_user_to_manage_multisite(); 2600 2601 wp_set_current_user( self::$user ); 2602 2603 $test_post = $this->factory->post->create(2597 $user_id = self::factory()->user->create(); 2598 2599 $this->allow_user_to_manage_multisite(); 2600 2601 wp_set_current_user( self::$user ); 2602 2603 $test_post = self::factory()->post->create( 2604 2604 array( 2605 2605 'post_author' => $user_id, … … 2623 2623 2624 2624 public function test_delete_user_reassign_passed_as_empty_string_trashes_post() { 2625 $user_id = $this->factory->user->create();2626 2627 $this->allow_user_to_manage_multisite(); 2628 2629 wp_set_current_user( self::$user ); 2630 2631 $test_post = $this->factory->post->create(2625 $user_id = self::factory()->user->create(); 2626 2627 $this->allow_user_to_manage_multisite(); 2628 2629 wp_set_current_user( self::$user ); 2630 2631 $test_post = self::factory()->post->create( 2632 2632 array( 2633 2633 'post_author' => $user_id, … … 2651 2651 2652 2652 public function test_delete_user_reassign_passed_as_0_reassigns_author() { 2653 $user_id = $this->factory->user->create();2654 2655 $this->allow_user_to_manage_multisite(); 2656 2657 wp_set_current_user( self::$user ); 2658 2659 $test_post = $this->factory->post->create(2653 $user_id = self::factory()->user->create(); 2654 2655 $this->allow_user_to_manage_multisite(); 2656 2657 wp_set_current_user( self::$user ); 2658 2659 $test_post = self::factory()->post->create( 2660 2660 array( 2661 2661 'post_author' => $user_id, … … 2832 2832 public function test_get_item_from_different_site_as_site_administrator() { 2833 2833 switch_to_blog( self::$site ); 2834 $user_id = $this->factory->user->create(2834 $user_id = self::factory()->user->create( 2835 2835 array( 2836 2836 'role' => 'author', … … 2852 2852 public function test_get_item_from_different_site_as_network_administrator() { 2853 2853 switch_to_blog( self::$site ); 2854 $user_id = $this->factory->user->create(2854 $user_id = self::factory()->user->create( 2855 2855 array( 2856 2856 'role' => 'author', … … 2872 2872 public function test_update_item_from_different_site_as_site_administrator() { 2873 2873 switch_to_blog( self::$site ); 2874 $user_id = $this->factory->user->create(2874 $user_id = self::factory()->user->create( 2875 2875 array( 2876 2876 'role' => 'author', … … 2894 2894 public function test_update_item_from_different_site_as_network_administrator() { 2895 2895 switch_to_blog( self::$site ); 2896 $user_id = $this->factory->user->create(2896 $user_id = self::factory()->user->create( 2897 2897 array( 2898 2898 'role' => 'author', … … 2916 2916 public function test_delete_item_from_different_site_as_site_administrator() { 2917 2917 switch_to_blog( self::$site ); 2918 $user_id = $this->factory->user->create(2918 $user_id = self::factory()->user->create( 2919 2919 array( 2920 2920 'role' => 'author', … … 2938 2938 public function test_delete_item_from_different_site_as_network_administrator() { 2939 2939 switch_to_blog( self::$site ); 2940 $user_id = $this->factory->user->create(2940 $user_id = self::factory()->user->create( 2941 2941 array( 2942 2942 'role' => 'author', -
trunk/tests/phpunit/tests/rest-api/wpRestMenusController.php
r52079 r54090 86 86 ); 87 87 88 $this->menu_id = $this->factory->term->create( $orig_args );88 $this->menu_id = self::factory()->term->create( $orig_args ); 89 89 90 90 register_meta( … … 134 134 $this->assertSame( array( 'v1' => true ), $data['endpoints'][0]['allow_batch'] ); 135 135 // Single. 136 $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) );136 $tag1 = self::factory()->tag->create( array( 'name' => 'Season 5' ) ); 137 137 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/menus/' . $tag1 ); 138 138 $response = rest_get_server()->dispatch( $request ); -
trunk/tests/phpunit/tests/taxonomy.php
r54052 r54090 682 682 ) 683 683 ); 684 $t = $this->factory->term->create_and_get(685 array( 686 'taxonomy' => 'wptests_tax', 687 ) 688 ); 689 690 $p = $this->factory->post->create();684 $t = self::factory()->term->create_and_get( 685 array( 686 'taxonomy' => 'wptests_tax', 687 ) 688 ); 689 690 $p = self::factory()->post->create(); 691 691 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 692 692 -
trunk/tests/phpunit/tests/term/cache.php
r52836 r54090 245 245 global $wpdb; 246 246 247 $term_id = $this->factory->term->create(247 $term_id = self::factory()->term->create( 248 248 array( 249 249 'slug' => 'burrito', … … 276 276 global $wpdb; 277 277 278 $term_id = $this->factory->term->create(278 $term_id = self::factory()->term->create( 279 279 array( 280 280 'slug' => 'burrito', … … 314 314 global $wpdb; 315 315 316 $term_id = $this->factory->term->