diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index a5750fd5bd9cd..4b4ba86c5c7d6 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -495,7 +495,7 @@ public function setup_block_editor_test( $hook = 'post.php' ) { $GLOBALS['hook_suffix'] = $hook; if ( 'post.php' === $hook ) { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_type' => 'type_shows_in_rest', ) diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 00b9501dcdb0f..9f2fdbc085386 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -230,7 +230,7 @@ public function test_get_post_templates_child_theme() { * @ticket 28121 */ public function test_get_theme_featured_list_api() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $featured_list_api = get_theme_feature_list( true ); $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); } diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php index 25813124159b6..2198fadcd0ddb 100644 --- a/tests/phpunit/tests/auth.php +++ b/tests/phpunit/tests/auth.php @@ -407,7 +407,7 @@ public function test_log_in_using_email() { 'user_email' => 'mail@example.com', 'user_pass' => 'password', ); - $this->factory->user->create( $user_args ); + self::factory()->user->create( $user_args ); $this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_email'], $user_args['user_pass'] ) ); $this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_login'], $user_args['user_pass'] ) ); diff --git a/tests/phpunit/tests/category/walkerCategory.php b/tests/phpunit/tests/category/walkerCategory.php index 4e711c4f23c6f..2728b11131168 100644 --- a/tests/phpunit/tests/category/walkerCategory.php +++ b/tests/phpunit/tests/category/walkerCategory.php @@ -30,7 +30,7 @@ public function set_up() { */ public function test_start_el_with_empty_attributes( $value, $expected ) { $output = ''; - $category = $this->factory->category->create_and_get(); + $category = self::factory()->category->create_and_get(); $link = get_term_link( $category ); $args = array( diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index a847784d87917..9683110030418 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -720,13 +720,13 @@ public function setup_notify_comment() { /** * Set up a comment for testing. */ - $post = $this->factory->post->create( + $post = self::factory()->post->create( array( 'post_author' => self::$user_id, ) ); - $comment = $this->factory->comment->create( + $comment = self::factory()->comment->create( array( 'comment_post_ID' => $post, ) diff --git a/tests/phpunit/tests/comment/checkComment.php b/tests/phpunit/tests/comment/checkComment.php index 0f02b63dbfe93..5efcf9acceedb 100644 --- a/tests/phpunit/tests/comment/checkComment.php +++ b/tests/phpunit/tests/comment/checkComment.php @@ -146,7 +146,7 @@ public function test_should_return_true_when_comment_previously_approved_is_enab ); // Make sure comment author has an approved comment. - $this->factory->comment->create( + self::factory()->comment->create( array( 'user_id' => $subscriber_id, 'comment_approved' => '1', diff --git a/tests/phpunit/tests/comment/commentsOpen.php b/tests/phpunit/tests/comment/commentsOpen.php index 54e08ea8ed1d5..7549498e900f6 100644 --- a/tests/phpunit/tests/comment/commentsOpen.php +++ b/tests/phpunit/tests/comment/commentsOpen.php @@ -17,7 +17,7 @@ public function test_post_does_not_exist() { * @ticket 54159 */ public function test_post_exist_status_open() { - $post = $this->factory->post->create_and_get(); + $post = self::factory()->post->create_and_get(); $this->assertTrue( comments_open( $post ) ); } @@ -25,7 +25,7 @@ public function test_post_exist_status_open() { * @ticket 54159 */ public function test_post_exist_status_closed() { - $post = $this->factory->post->create_and_get(); + $post = self::factory()->post->create_and_get(); $post->comment_status = 'closed'; $this->assertFalse( comments_open( $post ) ); diff --git a/tests/phpunit/tests/comment/pingsOpen.php b/tests/phpunit/tests/comment/pingsOpen.php index 2ef7029804c8e..93a25d5a73e9d 100644 --- a/tests/phpunit/tests/comment/pingsOpen.php +++ b/tests/phpunit/tests/comment/pingsOpen.php @@ -17,7 +17,7 @@ public function test_post_does_not_exist() { * @ticket 54159 */ public function test_post_exist_status_open() { - $post = $this->factory->post->create_and_get(); + $post = self::factory()->post->create_and_get(); $this->assertTrue( pings_open( $post ) ); } @@ -25,7 +25,7 @@ public function test_post_exist_status_open() { * @ticket 54159 */ public function test_post_exist_status_closed() { - $post = $this->factory->post->create_and_get(); + $post = self::factory()->post->create_and_get(); $post->ping_status = 'closed'; $this->assertFalse( pings_open( $post ) ); diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 7cb089d54a971..0632a22863279 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -58,7 +58,7 @@ public function test_get_comments_number_without_arg() { */ public function test_get_comments_number_text_with_post_id() { $post_id = self::$post_id; - $this->factory->comment->create_post_comments( $post_id, 6 ); + self::factory()->comment->create_post_comments( $post_id, 6 ); $comments_number_text = get_comments_number_text( false, false, false, $post_id ); @@ -84,12 +84,12 @@ public function test_get_comments_number_text_declension_with_default_args() { $this->assertSame( __( 'No Comments' ), get_comments_number_text() ); - $this->factory->comment->create_post_comments( $post_id, 1 ); + self::factory()->comment->create_post_comments( $post_id, 1 ); $this->go_to( $permalink ); $this->assertSame( __( '1 Comment' ), get_comments_number_text() ); - $this->factory->comment->create_post_comments( $post_id, 1 ); + self::factory()->comment->create_post_comments( $post_id, 1 ); $this->go_to( $permalink ); $this->assertSame( sprintf( _n( '%s Comment', '%s Comments', 2 ), '2' ), get_comments_number_text() ); @@ -106,7 +106,7 @@ public function test_get_comments_number_text_declension_with_custom_args( $numb $post_id = self::$post_id; $permalink = get_permalink( $post_id ); - $this->factory->comment->create_post_comments( $post_id, $number ); + self::factory()->comment->create_post_comments( $post_id, $number ); $this->go_to( $permalink ); add_filter( 'gettext_with_context', array( $this, 'enable_comment_number_declension' ), 10, 4 ); diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 429afed1f7943..5785558103c95 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -417,7 +417,7 @@ public function test_search_available_items_query_should_return_unassigned_term_ ) ); - $term_id = $this->factory->term->create( + $term_id = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foobar', diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php index 23d97aa4730a5..c1d9edb66cb98 100644 --- a/tests/phpunit/tests/date/getFeedBuildDate.php +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -55,7 +55,7 @@ public function test_should_fall_back_to_last_post_modified() { $this->assertFalse( get_feed_build_date( DATE_RFC3339 ), 'False when unable to determine valid time' ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_date' => $datetime->format( 'Y-m-d H:i:s' ), ) @@ -68,7 +68,7 @@ public function test_should_fall_back_to_last_post_modified() { 'Fall back to time of last post modified with no posts' ); - $post_id_broken = $this->factory->post->create(); + $post_id_broken = self::factory()->post->create(); $post_broken = get_post( $post_id_broken ); $post_broken->post_modified_gmt = 0; diff --git a/tests/phpunit/tests/date/getTheModifiedDate.php b/tests/phpunit/tests/date/getTheModifiedDate.php index 9b0dad77cf29d..7189a7282c669 100644 --- a/tests/phpunit/tests/date/getTheModifiedDate.php +++ b/tests/phpunit/tests/date/getTheModifiedDate.php @@ -20,7 +20,7 @@ public function test_get_the_modified_date_with_post_id() { 'post_date' => '2016-01-21 15:34:36', 'post_date_gmt' => '2016-01-21 15:34:36', ); - $post_id = $this->factory->post->create( $details ); + $post_id = self::factory()->post->create( $details ); $format = 'Y-m-d'; $expected = '2016-01-21'; $actual = get_the_modified_date( $format, $post_id ); @@ -39,7 +39,7 @@ public function test_get_the_modified_date_default() { 'post_date' => '2016-01-21 15:34:36', 'post_date_gmt' => '2016-01-21 15:34:36', ); - $post_id = $this->factory->post->create( $details ); + $post_id = self::factory()->post->create( $details ); $post = get_post( $post_id ); $GLOBALS['post'] = $post; @@ -111,7 +111,7 @@ public function test_get_the_modified_time_with_post_id() { 'post_date' => '2016-01-21 15:34:36', 'post_date_gmt' => '2016-01-21 15:34:36', ); - $post_id = $this->factory->post->create( $details ); + $post_id = self::factory()->post->create( $details ); $format = 'G'; $expected = 1453390476; $actual = get_the_modified_time( $format, $post_id ); @@ -130,7 +130,7 @@ public function test_get_the_modified_time_default() { 'post_date' => '2016-01-21 15:34:36', 'post_date_gmt' => '2016-01-21 15:34:36', ); - $post_id = $this->factory->post->create( $details ); + $post_id = self::factory()->post->create( $details ); $post = get_post( $post_id ); $GLOBALS['post'] = $post; diff --git a/tests/phpunit/tests/date/xmlrpc.php b/tests/phpunit/tests/date/xmlrpc.php index 8a4efaf46d2b6..6344265e1f98c 100644 --- a/tests/phpunit/tests/date/xmlrpc.php +++ b/tests/phpunit/tests/date/xmlrpc.php @@ -221,7 +221,7 @@ public function test_date_edit_comment() { $datetimeutc = $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); $this->make_user_by_role( 'administrator' ); - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); $comment_data = array( 'comment_post_ID' => $post_id, diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 88c1092e0c6d3..8a29853526960 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -104,7 +104,7 @@ public function test_has_site_icon() { * @covers ::has_site_icon */ public function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $this->set_site_icon(); restore_current_blog(); @@ -119,7 +119,7 @@ public function test_has_site_icon_returns_true_when_called_for_other_site_with_ * @covers ::has_site_icon */ public function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); $this->assertFalse( has_site_icon( $blog_id ) ); } @@ -298,7 +298,7 @@ public function test_has_custom_logo() { * @covers ::has_custom_logo */ public function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $this->set_custom_logo(); restore_current_blog(); @@ -313,7 +313,7 @@ public function test_has_custom_logo_returns_true_when_called_for_other_site_wit * @covers ::has_custom_logo */ public function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); $this->assertFalse( has_custom_logo( $blog_id ) ); } @@ -343,7 +343,7 @@ public function test_get_custom_logo() { * @covers ::get_custom_logo */ public function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $this->set_custom_logo(); @@ -466,7 +466,7 @@ private function insert_custom_logo() { * @covers ::get_site_icon_url */ public function test_get_site_icon_url_preserves_switched_state() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $expected = $GLOBALS['_wp_switched_stack']; @@ -486,7 +486,7 @@ public function test_get_site_icon_url_preserves_switched_state() { * @covers ::has_custom_logo */ public function test_has_custom_logo_preserves_switched_state() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $expected = $GLOBALS['_wp_switched_stack']; @@ -506,7 +506,7 @@ public function test_has_custom_logo_preserves_switched_state() { * @covers ::get_custom_logo */ public function test_get_custom_logo_preserves_switched_state() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $expected = $GLOBALS['_wp_switched_stack']; diff --git a/tests/phpunit/tests/general/wpGetDocumentTitle.php b/tests/phpunit/tests/general/wpGetDocumentTitle.php index b7b82c7093416..b12990fd5c665 100644 --- a/tests/phpunit/tests/general/wpGetDocumentTitle.php +++ b/tests/phpunit/tests/general/wpGetDocumentTitle.php @@ -101,7 +101,7 @@ public function test_front_page_title() { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page', @@ -128,7 +128,7 @@ public function front_page_title_parts( $parts ) { } public function test_home_title() { - $blog_page_id = $this->factory->post->create( + $blog_page_id = self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page', @@ -205,7 +205,7 @@ public function test_post_type_archive_title() { ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_type' => 'cpt', ) diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 75e5514c8baef..98b2608c87abf 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -658,7 +658,7 @@ public function test_wp_generate_attachment_metadata_pdf() { $this->markTestSkipped( $editor->get_error_message() ); } - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( @@ -735,7 +735,7 @@ public function test_crop_setting_for_pdf() { $this->markTestSkipped( $editor->get_error_message() ); } - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( @@ -808,7 +808,7 @@ public function test_fallback_intermediate_image_sizes() { $this->markTestSkipped( $editor->get_error_message() ); } - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( @@ -882,7 +882,7 @@ public function test_pdf_preview_doesnt_overwrite_existing_jpeg() { $this->markTestSkipped( $editor->get_error_message() ); } - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $pdf_path, 0, array( diff --git a/tests/phpunit/tests/link/getPostTypeArchiveLink.php b/tests/phpunit/tests/link/getPostTypeArchiveLink.php index e658b78725f67..7f3da3f30f66f 100644 --- a/tests/phpunit/tests/link/getPostTypeArchiveLink.php +++ b/tests/phpunit/tests/link/getPostTypeArchiveLink.php @@ -19,7 +19,7 @@ public function test_get_post_archive_link_with_post_archive_on_front_page() { * @ticket 19902 */ public function test_get_post_archive_link_with_post_archive_on_a_blog_page() { - $page_for_posts = $this->factory->post->create( + $page_for_posts = self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page', diff --git a/tests/phpunit/tests/link/getThePrivacyPolicyLink.php b/tests/phpunit/tests/link/getThePrivacyPolicyLink.php index 97d321b805b9c..942ae20c41c89 100644 --- a/tests/phpunit/tests/link/getThePrivacyPolicyLink.php +++ b/tests/phpunit/tests/link/getThePrivacyPolicyLink.php @@ -115,7 +115,7 @@ public function test_get_the_privacy_policy_link_should_not_prepend_and_append_s * @ticket 44192 */ public function test_function_should_return_empty_string_when_privacy_page_title_empty() { - $nameless_page_id = $this->factory->post->create( + $nameless_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => '', diff --git a/tests/phpunit/tests/media/getPostGalleries.php b/tests/phpunit/tests/media/getPostGalleries.php index bc34ef02d0ec1..363fea8149603 100644 --- a/tests/phpunit/tests/media/getPostGalleries.php +++ b/tests/phpunit/tests/media/getPostGalleries.php @@ -28,7 +28,7 @@ public function test_returns_empty_array_with_non_existent_post() { * @ticket 43826 */ public function test_returns_empty_array_with_post_with_no_gallery() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '
A post with no gallery
', ) @@ -49,7 +49,7 @@ public function test_returns_empty_array_with_post_with_no_gallery() { * @param string $needle The content of a non-gallery block. */ public function test_returns_only_galleries( $content, $needle ) { - $image_id = $this->factory->attachment->create_object( + $image_id = self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -66,7 +66,7 @@ public function test_returns_only_galleries( $content, $needle ) { $content ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $content, ) @@ -124,7 +124,7 @@ class="wp-image-IMAGE_ID" */ public function test_returns_no_srcs_with_shortcode_in_post_with_no_attached_images() { // Set up an unattached image. - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -133,7 +133,7 @@ public function test_returns_no_srcs_with_shortcode_in_post_with_no_attached_ima ) ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '[gallery]', ) @@ -173,7 +173,7 @@ public function test_returns_no_srcs_with_shortcode_in_post_with_no_attached_ima */ public function test_returns_no_srcs_with_block_in_post_with_no_attached_images() { // Set up an unattached image. - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -182,7 +182,7 @@ public function test_returns_no_srcs_with_block_in_post_with_no_attached_images( ) ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '', ) @@ -231,7 +231,7 @@ public function test_returns_no_srcs_with_block_in_post_with_no_attached_images( */ public function test_returns_no_srcs_with_block_v2_in_post_with_no_attached_images() { // Set up an unattached image. - $image_id = $this->factory->attachment->create_object( + $image_id = self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -260,7 +260,7 @@ class="wp-image-$image_id" BLOB; - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $blob, ) @@ -309,19 +309,19 @@ class="wp-image-$image_id" * @group shortcode */ public function test_returns_html_with_shortcode_gallery() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => 'I have no gallery', ) ); - $post_id_two = $this->factory->post->create( + $post_id_two = self::factory()->post->create( array( 'post_content' => "[gallery id='$post_id']", ) ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -363,14 +363,14 @@ public function test_returns_html_with_shortcode_gallery() { * @group blocks */ public function test_returns_html_with_block_gallery() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => 'I have no gallery.', ) ); // Set up an unattached image. - $image_id = $this->factory->attachment->create( + $image_id = self::factory()->attachment->create( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -387,7 +387,7 @@ public function test_returns_html_with_block_gallery() { BLOB; - $post_id_two = $this->factory->post->create( + $post_id_two = self::factory()->post->create( array( 'post_content' => $blob, ) @@ -426,7 +426,7 @@ public function test_returns_html_with_block_gallery() { * @group blocks */ public function test_returns_html_with_block_gallery_v2() { - $image_id = $this->factory->attachment->create_object( + $image_id = self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -455,7 +455,7 @@ class="wp-image-$image_id" BLOB; - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $blob, ) @@ -495,17 +495,17 @@ class="wp-image-$image_id" * @group shortcode */ public function test_respects_post_id_with_shortcode_gallery() { - $global_post_id = $this->factory->post->create( + $global_post_id = self::factory()->post->create( array( 'post_content' => 'Global Post', ) ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '[gallery]', ) ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -577,7 +577,7 @@ public function test_respects_post_id_with_block_gallery() { $ids_joined = join( ',', $ids ); - $global_post_id = $this->factory->post->create( + $global_post_id = self::factory()->post->create( array( 'post_content' => 'Global Post', ) @@ -588,12 +588,12 @@ public function test_respects_post_id_with_block_gallery() { BLOB; - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $blob, ) ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -657,7 +657,7 @@ public function test_respects_post_id_with_block_gallery_v2() { ); $metadata = array_merge( array( 'file' => 'image1.jpg' ), self::IMG_META ); $url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . 'image1.jpg'; - $global_post_id = $this->factory->post->create( + $global_post_id = self::factory()->post->create( array( 'post_content' => 'Global Post', ) @@ -683,12 +683,12 @@ class="wp-image-$attachment_id" BLOB; - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $blob, ) ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -742,17 +742,17 @@ class="wp-image-$attachment_id" * @group shortcode */ public function test_respects_shortcode_id_attribute() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => 'No gallery defined', ) ); - $post_id_two = $this->factory->post->create( + $post_id_two = self::factory()->post->create( array( 'post_content' => "[gallery id='$post_id']", ) ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -950,7 +950,7 @@ public function test_respects_additional_shortcode_and_block_attributes() { */ public function test_returns_srcs_from_html_with_block_with_no_json_blob() { // Set up an unattached image. - $image_id = $this->factory->attachment->create_object( + $image_id = self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => 0, @@ -972,7 +972,7 @@ public function test_returns_srcs_from_html_with_block_with_no_json_blob() { BLOB; - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => $blob, ) @@ -1022,12 +1022,12 @@ public function test_returns_srcs_from_html_with_block_with_no_json_blob() { * @group blocks */ public function test_returns_srcs_with_nested_block_gallery() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => 'I have no gallery.', ) ); - $image_id = $this->factory->attachment->create_object( + $image_id = self::factory()->attachment->create_object( array( 'file' => 'test.jpg', 'post_parent' => $post_id, @@ -1045,7 +1045,7 @@ public function test_returns_srcs_with_nested_block_gallery() { BLOB; - $post_id_two = $this->factory->post->create( array( 'post_content' => $blob ) ); + $post_id_two = self::factory()->post->create( array( 'post_content' => $blob ) ); $galleries = get_post_galleries( $post_id_two, false ); diff --git a/tests/phpunit/tests/menu/walker-nav-menu-edit.php b/tests/phpunit/tests/menu/walker-nav-menu-edit.php index 30ae8f81b0a31..0df5531975652 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu-edit.php +++ b/tests/phpunit/tests/menu/walker-nav-menu-edit.php @@ -40,7 +40,7 @@ public function tear_down() { public function test_original_title_prefix_should_not_be_shown_if_empty() { $expected = ''; - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); $item = array( 'classes' => array(), diff --git a/tests/phpunit/tests/menu/walker-nav-menu.php b/tests/phpunit/tests/menu/walker-nav-menu.php index f530d43e1056f..1dda827c1e0cc 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu.php +++ b/tests/phpunit/tests/menu/walker-nav-menu.php @@ -49,7 +49,7 @@ public function tear_down() { */ public function test_noopener_no_referrer_for_target_blank() { $actual = ''; - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); $post_title = get_the_title( $post_id ); $item = array( @@ -80,7 +80,7 @@ public function test_noopener_no_referrer_for_target_blank() { */ public function test_start_el_with_empty_attributes( $value, $expected ) { $output = ''; - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); $post_title = get_the_title( $post_id ); $item = array( diff --git a/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php b/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php index 232b729c231d2..9fceb5fc955b2 100644 --- a/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php +++ b/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php @@ -104,7 +104,7 @@ public function test_search_returns_results_for_published_posts() { public function test_search_should_return_unassigned_term_items() { register_taxonomy( 'wptests_tax', 'post' ); - $this->factory->term->create( + self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foobar', diff --git a/tests/phpunit/tests/multisite/wpInstallDefaults.php b/tests/phpunit/tests/multisite/wpInstallDefaults.php index c48a832a05cdc..cb05566a37d60 100644 --- a/tests/phpunit/tests/multisite/wpInstallDefaults.php +++ b/tests/phpunit/tests/multisite/wpInstallDefaults.php @@ -13,7 +13,7 @@ class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase { * @ticket 40036 */ public function test_option_should_not_be_empty_by_default() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); @@ -39,7 +39,7 @@ public function test_empty_option_should_fall_back_to_default() { update_site_option( 'first_page', '' ); update_site_option( 'first_comment', '' ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); @@ -65,7 +65,7 @@ public function test_non_default_option_values() { update_site_option( 'first_page', 'Some page content' ); update_site_option( 'first_comment', 'Some comment content' ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 9e204804e6873..6f07ca859364c 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -454,7 +454,7 @@ public function test_wp_delete_post_reassign_hierarchical_post_type() { public function test_pre_wp_unique_post_slug_filter() { add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'title' => 'An example', 'post_status' => 'publish', diff --git a/tests/phpunit/tests/post/walkerPage.php b/tests/phpunit/tests/post/walkerPage.php index 6b71bb021667b..a5a632dcdaa85 100644 --- a/tests/phpunit/tests/post/walkerPage.php +++ b/tests/phpunit/tests/post/walkerPage.php @@ -28,7 +28,7 @@ public function set_up() { */ public function test_start_el_with_empty_attributes( $value, $expected ) { $output = ''; - $page = $this->factory->post->create_and_get( array( 'post_type' => 'page' ) ); + $page = self::factory()->post->create_and_get( array( 'post_type' => 'page' ) ); $link = get_permalink( $page ); add_filter( diff --git a/tests/phpunit/tests/post/wpPublishPost.php b/tests/phpunit/tests/post/wpPublishPost.php index a8c0227b0ced2..25fa87a71c91d 100644 --- a/tests/phpunit/tests/post/wpPublishPost.php +++ b/tests/phpunit/tests/post/wpPublishPost.php @@ -142,7 +142,7 @@ public function test_wp_publish_post_and_avoid_content_filtering() { */ public function test_wp_publish_post_respects_current_categories() { $post_id = self::$auto_draft_id; - $category_id = $this->factory->term->create( array( 'taxonomy' => 'category' ) ); + $category_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); wp_set_post_categories( $post_id, $category_id ); wp_publish_post( $post_id ); @@ -183,7 +183,7 @@ public function test_wp_publish_post_adds_default_category() { */ public function test_wp_publish_post_adds_default_category_when_tagged() { $post_id = self::$auto_draft_id; - $tag_id = $this->factory->term->create( array( 'taxonomy' => 'post_tag' ) ); + $tag_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) ); wp_set_post_tags( $post_id, array( $tag_id ) ); wp_publish_post( $post_id ); @@ -218,7 +218,7 @@ public function test_wp_publish_post_respects_current_terms() { ); $post_id = self::$auto_draft_id; - $term_id = $this->factory->term->create( array( 'taxonomy' => 'tax_51292' ) ); + $term_id = self::factory()->term->create( array( 'taxonomy' => 'tax_51292' ) ); wp_set_object_terms( $post_id, array( $term_id ), 'tax_51292' ); wp_publish_post( $post_id ); diff --git a/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php index 96b4e0ecd9651..ef71a5f85de39 100644 --- a/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php +++ b/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php @@ -131,7 +131,7 @@ public function test_should_send_email_no_privacy_policy() { * @ticket 44234 */ public function test_should_send_email_with_privacy_policy() { - $privacy_policy = $this->factory->post->create( + $privacy_policy = self::factory()->post->create( array( 'post_type' => 'page', 'title' => 'Site Privacy Policy', @@ -307,7 +307,7 @@ public function test_should_not_send_email_when_passed_invalid_request_id() { * @ticket 44234 */ public function test_should_not_send_email_when_not_user_request() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_type' => 'post', // Should be 'user_request'. ) diff --git a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php index f2933bdda0cfe..ee083b30c6bad 100644 --- a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php +++ b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php @@ -55,7 +55,7 @@ public function test_function_should_not_send_email_when_not_a_valid_request_id( * @ticket 43967 */ public function test_function_should_not_send_email_when_not_a_wp_user_request() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_type' => 'post', ) diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index 9a8a9b3ffd4db..fef3e197482b2 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -644,19 +644,19 @@ public function test_get_queried_object_should_return_first_of_multiple_terms() register_taxonomy( 'tax1', 'post' ); register_taxonomy( 'tax2', 'post' ); - $term1 = $this->factory->term->create( + $term1 = self::factory()->term->create( array( 'taxonomy' => 'tax1', 'name' => 'term1', ) ); - $term2 = $this->factory->term->create( + $term2 = self::factory()->term->create( array( 'taxonomy' => 'tax2', 'name' => 'term2', ) ); - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_object_terms( $post_id, 'term1', 'tax1' ); wp_set_object_terms( $post_id, 'term2', 'tax2' ); @@ -674,19 +674,19 @@ public function test_query_vars_should_match_first_of_multiple_terms() { register_taxonomy( 'tax1', 'post' ); register_taxonomy( 'tax2', 'post' ); - $term1 = $this->factory->term->create( + $term1 = self::factory()->term->create( array( 'taxonomy' => 'tax1', 'name' => 'term1', ) ); - $term2 = $this->factory->term->create( + $term2 = self::factory()->term->create( array( 'taxonomy' => 'tax2', 'name' => 'term2', ) ); - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_object_terms( $post_id, 'term1', 'tax1' ); wp_set_object_terms( $post_id, 'term2', 'tax2' ); diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 95621882b0384..c447c638d6986 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -978,13 +978,13 @@ public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_ public function test_is_single_with_slug_that_clashes_with_attachment() { $this->set_permalink_structure( '/%postname%/' ); - $attachment_id = $this->factory->post->create( + $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment', ) ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_title' => get_post( $attachment_id )->post_title, ) diff --git a/tests/phpunit/tests/query/noFoundRows.php b/tests/phpunit/tests/query/noFoundRows.php index 457da449942a4..7b4f66a416030 100644 --- a/tests/phpunit/tests/query/noFoundRows.php +++ b/tests/phpunit/tests/query/noFoundRows.php @@ -73,7 +73,7 @@ public function test_no_found_rows_non_bool_cast_to_true() { * @ticket 29552 */ public function test_no_found_rows_default_with_nopaging_true() { - $p = $this->factory->post->create(); + $p = self::factory()->post->create(); $q = new WP_Query( array( @@ -90,7 +90,7 @@ public function test_no_found_rows_default_with_nopaging_true() { * @ticket 29552 */ public function test_no_found_rows_default_with_postsperpage_minus1() { - $p = $this->factory->post->create(); + $p = self::factory()->post->create(); $q = new WP_Query( array( diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index 418acbfc8520b..954bd5f748db4 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -266,7 +266,7 @@ public function test_search_orderby_should_be_empty_when_search_string_is_longer * @ticket 31025 */ public function test_s_zero() { - $p1 = $this->factory->post->create( + $p1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_title' => '1', @@ -275,7 +275,7 @@ public function test_s_zero() { ) ); - $p2 = $this->factory->post->create( + $p2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_title' => '0', diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 2c97f81c05c14..05f6aab921347 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -185,7 +185,7 @@ public function test_context_param() { $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -246,7 +246,7 @@ public function test_registered_query_params() { } public function test_registered_get_item_params() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -266,7 +266,7 @@ public function test_registered_get_item_params() { * @ticket 43701 */ public function test_allow_header_sent_on_options_request() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -294,7 +294,7 @@ public function test_allow_header_sent_on_options_request() { public function test_get_items() { wp_set_current_user( 0 ); - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -302,8 +302,8 @@ public function test_get_items() { 'post_excerpt' => 'A sample caption', ) ); - $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $id2 = $this->factory->attachment->create_object( + $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); + $id2 = self::factory()->attachment->create_object( $this->test_file, $draft_post, array( @@ -311,8 +311,8 @@ public function test_get_items() { 'post_excerpt' => 'A sample caption', ) ); - $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->attachment->create_object( + $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->attachment->create_object( $this->test_file, $published_post, array( @@ -334,7 +334,7 @@ public function test_get_items() { public function test_get_items_logged_in_editor() { wp_set_current_user( self::$editor_id ); - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -342,8 +342,8 @@ public function test_get_items_logged_in_editor() { 'post_excerpt' => 'A sample caption', ) ); - $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $id2 = $this->factory->attachment->create_object( + $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); + $id2 = self::factory()->attachment->create_object( $this->test_file, $draft_post, array( @@ -351,8 +351,8 @@ public function test_get_items_logged_in_editor() { 'post_excerpt' => 'A sample caption', ) ); - $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->attachment->create_object( + $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->attachment->create_object( $this->test_file, $published_post, array( @@ -372,7 +372,7 @@ public function test_get_items_logged_in_editor() { } public function test_get_items_media_type() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -395,7 +395,7 @@ public function test_get_items_media_type() { } public function test_get_items_mime_type() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -418,8 +418,8 @@ public function test_get_items_mime_type() { } public function test_get_items_parent() { - $post_id = $this->factory->post->create( array( 'post_title' => 'Test Post' ) ); - $attachment_id = $this->factory->attachment->create_object( + $post_id = self::factory()->post->create( array( 'post_title' => 'Test Post' ) ); + $attachment_id = self::factory()->attachment->create_object( $this->test_file, $post_id, array( @@ -427,7 +427,7 @@ public function test_get_items_parent() { 'post_excerpt' => 'A sample caption', ) ); - $attachment_id2 = $this->factory->attachment->create_object( + $attachment_id2 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -463,7 +463,7 @@ public function test_get_items_parent() { public function test_get_items_invalid_status_param_is_error_response() { wp_set_current_user( self::$editor_id ); - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -481,7 +481,7 @@ public function test_get_items_invalid_status_param_is_error_response() { public function test_get_items_private_status() { // Logged out users can't make the request. wp_set_current_user( 0 ); - $attachment_id1 = $this->factory->attachment->create_object( + $attachment_id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -505,7 +505,7 @@ public function test_get_items_private_status() { public function test_get_items_multiple_statuses() { // Logged out users can't make the request. wp_set_current_user( 0 ); - $attachment_id1 = $this->factory->attachment->create_object( + $attachment_id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -514,7 +514,7 @@ public function test_get_items_multiple_statuses() { 'post_status' => 'private', ) ); - $attachment_id2 = $this->factory->attachment->create_object( + $attachment_id2 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -550,7 +550,7 @@ public function test_get_items_invalid_date() { } public function test_get_items_valid_date() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -559,7 +559,7 @@ public function test_get_items_valid_date() { 'post_excerpt' => 'A sample caption', ) ); - $id2 = $this->factory->attachment->create_object( + $id2 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -568,7 +568,7 @@ public function test_get_items_valid_date() { 'post_excerpt' => 'A sample caption', ) ); - $id3 = $this->factory->attachment->create_object( + $id3 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -601,7 +601,7 @@ public function test_get_items_invalid_modified_date() { * @ticket 50617 */ public function test_get_items_valid_modified_date() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -610,7 +610,7 @@ public function test_get_items_valid_modified_date() { 'post_excerpt' => 'A sample caption', ) ); - $id2 = $this->factory->attachment->create_object( + $id2 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -619,7 +619,7 @@ public function test_get_items_valid_modified_date() { 'post_excerpt' => 'A sample caption', ) ); - $id3 = $this->factory->attachment->create_object( + $id3 = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -661,7 +661,7 @@ public function test_get_items_avoid_duplicated_count_query_if_no_items() { * @ticket 55677 */ public function test_get_items_with_empty_page_runs_count_query_after() { - $this->factory->attachment->create_object( + self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -683,7 +683,7 @@ public function test_get_items_with_empty_page_runs_count_query_after() { } public function test_get_item() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -703,7 +703,7 @@ public function test_get_item() { * @requires function imagejpeg */ public function test_get_item_sizes() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -734,7 +734,7 @@ public function test_get_item_sizes() { * @requires function imagejpeg */ public function test_get_item_sizes_with_no_url() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -761,8 +761,8 @@ public function test_get_item_sizes_with_no_url() { public function test_get_item_private_post_not_authenticated() { wp_set_current_user( 0 ); - $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $id1 = $this->factory->attachment->create_object( + $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) ); + $id1 = self::factory()->attachment->create_object( $this->test_file, $draft_post, array( @@ -776,7 +776,7 @@ public function test_get_item_private_post_not_authenticated() { } public function test_get_item_inherit_status_with_invalid_parent() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( @@ -793,7 +793,7 @@ public function test_get_item_inherit_status_with_invalid_parent() { } public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( @@ -963,7 +963,7 @@ public function test_create_item_invalid_upload_files_capability() { } public function test_create_item_invalid_edit_permissions() { - $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) ); + $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); wp_set_current_user( self::$author_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); $request->set_param( 'post', $post_id ); @@ -972,7 +972,7 @@ public function test_create_item_invalid_edit_permissions() { } public function test_create_item_invalid_upload_permissions() { - $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) ); + $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); wp_set_current_user( self::$uploader_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); $request->set_param( 'post', $post_id ); @@ -981,7 +981,7 @@ public function test_create_item_invalid_upload_permissions() { } public function test_create_item_invalid_post_type() { - $attachment_id = $this->factory->post->create( + $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', @@ -1046,7 +1046,7 @@ public function test_create_item_ensure_relative_path() { public function test_update_item() { wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1075,8 +1075,8 @@ public function test_update_item() { public function test_update_item_parent() { wp_set_current_user( self::$editor_id ); - $original_parent = $this->factory->post->create( array() ); - $attachment_id = $this->factory->attachment->create_object( + $original_parent = self::factory()->post->create( array() ); + $attachment_id = self::factory()->attachment->create_object( $this->test_file, $original_parent, array( @@ -1089,7 +1089,7 @@ public function test_update_item_parent() { $attachment = get_post( $attachment_id ); $this->assertSame( $original_parent, $attachment->post_parent ); - $new_parent = $this->factory->post->create( array() ); + $new_parent = self::factory()->post->create( array() ); $request = new WP_REST_Request( 'POST', '/wp/v2/media/' . $attachment_id ); $request->set_param( 'post', $new_parent ); rest_get_server()->dispatch( $request ); @@ -1100,7 +1100,7 @@ public function test_update_item_parent() { public function test_update_item_invalid_permissions() { wp_set_current_user( self::$author_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1116,7 +1116,7 @@ public function test_update_item_invalid_permissions() { } public function test_update_item_invalid_post_type() { - $attachment_id = $this->factory->post->create( + $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', @@ -1124,7 +1124,7 @@ public function test_update_item_invalid_post_type() { ) ); wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1448,7 +1448,7 @@ public function test_attachment_roundtrip_as_superadmin_unfiltered_html() { public function test_delete_item() { wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1464,7 +1464,7 @@ public function test_delete_item() { public function test_delete_item_no_trash() { wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1489,7 +1489,7 @@ public function test_delete_item_no_trash() { public function test_delete_item_invalid_delete_permissions() { wp_set_current_user( self::$author_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1504,7 +1504,7 @@ public function test_delete_item_invalid_delete_permissions() { } public function test_prepare_item() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1523,7 +1523,7 @@ public function test_prepare_item() { } public function test_prepare_item_limit_fields() { - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1614,7 +1614,7 @@ public function test_get_additional_field_registration() { $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1651,7 +1651,7 @@ public function test_additional_field_update_errors() { ); wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( @@ -1677,14 +1677,14 @@ public function test_additional_field_update_errors() { } public function test_search_item_by_filename() { - $id1 = $this->factory->attachment->create_object( + $id1 = self::factory()->attachment->create_object( $this->test_file, 0, array( 'post_mime_type' => 'image/jpeg', ) ); - $id2 = $this->factory->attachment->create_object( + $id2 = self::factory()->attachment->create_object( $this->test_file2, 0, array( @@ -1935,7 +1935,7 @@ public function test_rest_insert_attachment_hooks_fire_once_on_update() { add_action( 'rest_after_insert_attachment', array( $this, 'filter_rest_after_insert_attachment' ) ); wp_set_current_user( self::$editor_id ); - $attachment_id = $this->factory->attachment->create_object( + $attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array( diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index ef72b6f8faded..805472487f021 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -121,7 +121,7 @@ public function test_context_param() { $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. - $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) ); + $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -172,9 +172,9 @@ public function test_get_items_invalid_permission_for_context() { } public function test_get_items_hide_empty_arg() { - $post_id = $this->factory->post->create(); - $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) ); - $category2 = $this->factory->category->create( array( 'name' => 'The Be Sharps' ) ); + $post_id = self::factory()->post->create(); + $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); + $category2 = self::factory()->category->create( array( 'name' => 'The Be Sharps' ) ); $total_categories = self::$total_categories + 2; @@ -197,15 +197,15 @@ public function test_get_items_hide_empty_arg() { } public function test_get_items_parent_zero_arg() { - $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) ); - $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) ); - $this->factory->category->create( + $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); + $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); + self::factory()->category->create( array( 'name' => 'Bart', 'parent' => $parent1, ) ); - $this->factory->category->create( + self::factory()->category->create( array( 'name' => 'Lisa', 'parent' => $parent2, @@ -229,15 +229,15 @@ public function test_get_items_parent_zero_arg() { } public function test_get_items_parent_zero_arg_string() { - $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) ); - $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) ); - $this->factory->category->create( + $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); + $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); + self::factory()->category->create( array( 'name' => 'Bart', 'parent' => $parent1, ) ); - $this->factory->category->create( + self::factory()->category->create( array( 'name' => 'Lisa', 'parent' => $parent2, @@ -261,7 +261,7 @@ public function test_get_items_parent_zero_arg_string() { } public function test_get_items_by_parent_non_found() { - $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) ); + $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'parent', $parent1 ); @@ -284,8 +284,8 @@ public function test_get_items_invalid_page() { } public function test_get_items_include_query() { - $id1 = $this->factory->category->create(); - $id2 = $this->factory->category->create(); + $id1 = self::factory()->category->create(); + $id2 = self::factory()->category->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -305,8 +305,8 @@ public function test_get_items_include_query() { } public function test_get_items_exclude_query() { - $id1 = $this->factory->category->create(); - $id2 = $this->factory->category->create(); + $id1 = self::factory()->category->create(); + $id2 = self::factory()->category->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'per_page', self::$per_page ); @@ -325,8 +325,8 @@ public function test_get_items_exclude_query() { } public function test_get_items_orderby_args() { - $this->factory->category->create( array( 'name' => 'Apple' ) ); - $this->factory->category->create( array( 'name' => 'Banana' ) ); + self::factory()->category->create( array( 'name' => 'Apple' ) ); + self::factory()->category->create( array( 'name' => 'Banana' ) ); /* * Tests: @@ -356,9 +356,9 @@ public function test_get_items_orderby_args() { } public function test_get_items_orderby_id() { - $this->factory->category->create( array( 'name' => 'Cantaloupe' ) ); - $this->factory->category->create( array( 'name' => 'Apple' ) ); - $this->factory->category->create( array( 'name' => 'Banana' ) ); + self::factory()->category->create( array( 'name' => 'Cantaloupe' ) ); + self::factory()->category->create( array( 'name' => 'Apple' ) ); + self::factory()->category->create( array( 'name' => 'Banana' ) ); // Defaults to 'orderby' => 'name', 'order' => 'asc'. $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -392,9 +392,9 @@ public function test_get_items_orderby_id() { } public function test_get_items_orderby_slugs() { - $this->factory->category->create( array( 'name' => 'Burrito' ) ); - $this->factory->category->create( array( 'name' => 'Taco' ) ); - $this->factory->category->create( array( 'name' => 'Chalupa' ) ); + self::factory()->category->create( array( 'name' => 'Burrito' ) ); + self::factory()->category->create( array( 'name' => 'Taco' ) ); + self::factory()->category->create( array( 'name' => 'Chalupa' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'orderby', 'include_slugs' ); @@ -408,20 +408,20 @@ public function test_get_items_orderby_slugs() { } protected function post_with_categories() { - $post_id = $this->factory->post->create(); - $category1 = $this->factory->category->create( + $post_id = self::factory()->post->create(); + $category1 = self::factory()->category->create( array( 'name' => 'DC', 'description' => 'Purveyor of fine detective comics', ) ); - $category2 = $this->factory->category->create( + $category2 = self::factory()->category->create( array( 'name' => 'Marvel', 'description' => 'Home of the Marvel Universe', ) ); - $category3 = $this->factory->category->create( + $category3 = self::factory()->category->create( array( 'name' => 'Image', 'description' => 'American independent comic publisher', @@ -493,25 +493,25 @@ public function test_get_items_custom_tax_post_args() { register_taxonomy( 'batman', 'post', array( 'show_in_rest' => true ) ); $controller = new WP_REST_Terms_Controller( 'batman' ); $controller->register_routes(); - $term1 = $this->factory->term->create( + $term1 = self::factory()->term->create( array( 'name' => 'Cape', 'taxonomy' => 'batman', ) ); - $term2 = $this->factory->term->create( + $term2 = self::factory()->term->create( array( 'name' => 'Mask', 'taxonomy' => 'batman', ) ); - $this->factory->term->create( + self::factory()->term->create( array( 'name' => 'Car', 'taxonomy' => 'batman', ) ); - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); $request = new WP_REST_Request( 'GET', '/wp/v2/batman' ); @@ -525,8 +525,8 @@ public function test_get_items_custom_tax_post_args() { } public function test_get_items_search_args() { - $this->factory->category->create( array( 'name' => 'Apple' ) ); - $this->factory->category->create( array( 'name' => 'Banana' ) ); + self::factory()->category->create( array( 'name' => 'Apple' ) ); + self::factory()->category->create( array( 'name' => 'Banana' ) ); /* * Tests: @@ -549,8 +549,8 @@ public function test_get_items_search_args() { } public function test_get_items_slug_arg() { - $this->factory->category->create( array( 'name' => 'Apple' ) ); - $this->factory->category->create( array( 'name' => 'Banana' ) ); + self::factory()->category->create( array( 'name' => 'Apple' ) ); + self::factory()->category->create( array( 'name' => 'Banana' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'slug', 'apple' ); @@ -562,8 +562,8 @@ public function test_get_items_slug_arg() { } public function test_get_terms_parent_arg() { - $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) ); - $this->factory->category->create( + $category1 = self::factory()->category->create( array( 'name' => 'Parent' ) ); + self::factory()->category->create( array( 'name' => 'Child', 'parent' => $category1, @@ -587,13 +587,13 @@ public function test_get_terms_invalid_parent_arg() { public function test_get_terms_private_taxonomy() { register_taxonomy( 'robin', 'post', array( 'public' => false ) ); - $this->factory->term->create( + self::factory()->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin', ) ); - $this->factory->term->create( + self::factory()->term->create( array( 'name' => 'Mask', 'taxonomy' => 'robin', @@ -632,7 +632,7 @@ public function test_get_terms_pagination_headers() { $this->assertStringContainsString( '<' . $next_link . '>; rel="next"', $headers['Link'] ); // 3rd page. - $this->factory->category->create(); + self::factory()->category->create(); $total_categories++; $total_pages++; $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -775,7 +775,7 @@ public function test_get_item_invalid_permission_for_context() { public function test_get_term_private_taxonomy() { register_taxonomy( 'robin', 'post', array( 'public' => false ) ); - $term1 = $this->factory->term->create( + $term1 = self::factory()->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin', @@ -789,7 +789,7 @@ public function test_get_term_private_taxonomy() { public function test_get_item_incorrect_taxonomy() { register_taxonomy( 'robin', 'post' ); - $term1 = $this->factory->term->create( + $term1 = self::factory()->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin', @@ -824,7 +824,7 @@ public function test_create_item() { public function test_create_item_term_already_exists() { wp_set_current_user( self::$administrator ); - $existing_id = $this->factory->category->create( array( 'name' => 'Existing' ) ); + $existing_id = self::factory()->category->create( array( 'name' => 'Existing' ) ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories' ); $request->set_param( 'name', 'Existing' ); @@ -890,7 +890,7 @@ public function test_create_item_with_parent() { public function test_create_item_invalid_parent() { wp_set_current_user( self::$administrator ); - $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'name', 'My Awesome Term' ); @@ -922,7 +922,7 @@ public function test_update_item() { 'slug' => 'original-slug', ); - $term = get_term_by( 'id', $this->factory->category->create( $orig_args ), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create( $orig_args ), 'category' ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'name', 'New Name' ); @@ -968,7 +968,7 @@ public function test_update_item_invalid_term() { public function test_update_item_incorrect_permissions() { wp_set_current_user( self::$subscriber ); - $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'name', 'Incorrect permissions' ); @@ -979,8 +979,8 @@ public function test_update_item_incorrect_permissions() { public function test_update_item_parent() { wp_set_current_user( self::$administrator ); - $parent = get_term_by( 'id', $this->factory->category->create(), 'category' ); - $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $parent = get_term_by( 'id', self::factory()->category->create(), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'parent', $parent->term_id ); @@ -994,12 +994,12 @@ public function test_update_item_parent() { public function test_update_item_remove_parent() { wp_set_current_user( self::$administrator ); - $old_parent_term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $old_parent_term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $new_parent_id = 0; $term = get_term_by( 'id', - $this->factory->category->create( + self::factory()->category->create( array( 'parent' => $old_parent_term->term_id, ) @@ -1021,7 +1021,7 @@ public function test_update_item_remove_parent() { public function test_update_item_invalid_parent() { wp_set_current_user( self::$administrator ); - $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); @@ -1032,7 +1032,7 @@ public function test_update_item_invalid_parent() { public function test_delete_item() { wp_set_current_user( self::$administrator ); - $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'force', true ); @@ -1046,7 +1046,7 @@ public function test_delete_item() { public function test_delete_item_no_trash() { wp_set_current_user( self::$administrator ); - $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); $response = rest_get_server()->dispatch( $request ); @@ -1076,7 +1076,7 @@ public function test_delete_item_invalid_term() { public function test_delete_item_incorrect_permissions() { wp_set_current_user( self::$subscriber ); - $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); + $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 ); @@ -1108,7 +1108,7 @@ public function test_prepare_item_limit_fields() { } public function test_prepare_taxonomy_term_child() { - $child = $this->factory->category->create( + $child = self::factory()->category->create( array( 'parent' => 1, ) @@ -1170,7 +1170,7 @@ public function test_get_additional_field_registration() { $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); - $category_id = $this->factory->category->create(); + $category_id = self::factory()->category->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $category_id ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index bf5d112d4e7d1..eb66ee5d418f7 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -237,7 +237,7 @@ public function test_get_items_with_password() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'password', 'toomanysecrets' ); @@ -261,7 +261,7 @@ public function test_get_items_with_password_without_post() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'password', 'toomanysecrets' ); @@ -284,7 +284,7 @@ public function test_get_items_with_password_with_multiple_post() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'password', 'toomanysecrets' ); @@ -302,7 +302,7 @@ public function test_get_password_items_without_edit_post_permission() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -321,7 +321,7 @@ public function test_get_password_items_with_edit_post_permission() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -340,7 +340,7 @@ public function test_get_items_without_private_post_permission() { 'comment_post_ID' => self::$private_id, ); - $private_comment = $this->factory->comment->create( $args ); + $private_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -359,7 +359,7 @@ public function test_get_items_with_private_post_permission() { 'comment_post_ID' => self::$private_id, ); - $private_comment = $this->factory->comment->create( $args ); + $private_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -373,7 +373,7 @@ public function test_get_items_with_private_post_permission() { public function test_get_items_with_invalid_post() { wp_set_current_user( 0 ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, @@ -394,7 +394,7 @@ public function test_get_items_with_invalid_post() { public function test_get_items_with_invalid_post_permission() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, @@ -424,7 +424,7 @@ public function test_get_items_no_permission_for_context() { public function test_get_items_no_post() { wp_set_current_user( self::$admin_id ); - $this->factory->comment->create_post_comments( 0, 2 ); + self::factory()->comment->create_post_comments( 0, 2 ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'post', 0 ); @@ -453,8 +453,8 @@ public function test_get_items_edit_context() { } public function test_get_items_for_post() { - $second_post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $second_post_id, 2 ); + $second_post_id = self::factory()->post->create(); + self::factory()->comment->create_post_comments( $second_post_id, 2 ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_query_params( @@ -478,8 +478,8 @@ public function test_get_items_include_query() { 'comment_post_ID' => self::$post_id, ); - $id1 = $this->factory->comment->create( $args ); - $id2 = $this->factory->comment->create( $args ); + $id1 = self::factory()->comment->create( $args ); + $id2 = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -518,8 +518,8 @@ public function test_get_items_exclude_query() { 'comment_post_ID' => self::$post_id, ); - $id1 = $this->factory->comment->create( $args ); - $id2 = $this->factory->comment->create( $args ); + $id1 = self::factory()->comment->create( $args ); + $id2 = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); @@ -574,7 +574,7 @@ public function test_get_items_order_query() { 'comment_post_ID' => self::$post_id, ); - $id = $this->factory->comment->create( $args ); + $id = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -598,7 +598,7 @@ public function test_get_items_order_query() { public function test_get_items_private_post_no_permissions() { wp_set_current_user( 0 ); - $post_id = $this->factory->post->create( array( 'post_status' => 'private' ) ); + $post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'post', $post_id ); @@ -616,11 +616,11 @@ public function test_get_items_author_arg() { 'user_id' => self::$author_id, ); - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $args['user_id'] = self::$subscriber_id; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); unset( $args['user_id'] ); - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); // Limit to comment author. $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); @@ -659,11 +659,11 @@ public function test_get_items_author_exclude_arg() { 'user_id' => self::$author_id, ); - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $args['user_id'] = self::$subscriber_id; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); unset( $args['user_id'] ); - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $total_comments = self::$total_comments + 3; @@ -709,12 +709,12 @@ public function test_get_items_parent_arg() { 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, ); - $parent_id = $this->factory->comment->create( $args ); - $parent_id2 = $this->factory->comment->create( $args ); + $parent_id = self::factory()->comment->create( $args ); + $parent_id2 = self::factory()->comment->create( $args ); $args['comment_parent'] = $parent_id; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $args['comment_parent'] = $parent_id2; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $total_comments = self::$total_comments + 4; @@ -745,12 +745,12 @@ public function test_get_items_parent_exclude_arg() { 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, ); - $parent_id = $this->factory->comment->create( $args ); - $parent_id2 = $this->factory->comment->create( $args ); + $parent_id = self::factory()->comment->create( $args ); + $parent_id2 = self::factory()->comment->create( $args ); $args['comment_parent'] = $parent_id; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $args['comment_parent'] = $parent_id2; - $this->factory->comment->create( $args ); + self::factory()->comment->create( $args ); $total_comments = self::$total_comments + 4; @@ -786,7 +786,7 @@ public function test_get_items_search_query() { 'comment_author' => 'Homer J Simpson', ); - $id = $this->factory->comment->create( $args ); + $id = self::factory()->comment->create( $args ); $total_comments = self::$total_comments + 1; @@ -825,7 +825,7 @@ public function test_get_comments_pagination_headers() { $this->assertStringContainsString( '<' . $next_link . '>; rel="next"', $headers['Link'] ); // 3rd page. - $this->factory->comment->create( + self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, ) @@ -895,19 +895,19 @@ public function test_get_comments_invalid_date() { } public function test_get_comments_valid_date() { - $comment1 = $this->factory->comment->create( + $comment1 = self::factory()->comment->create( array( 'comment_date' => '2016-01-15T00:00:00Z', 'comment_post_ID' => self::$post_id, ) ); - $comment2 = $this->factory->comment->create( + $comment2 = self::factory()->comment->create( array( 'comment_date' => '2016-01-16T00:00:00Z', 'comment_post_ID' => self::$post_id, ) ); - $comment3 = $this->factory->comment->create( + $comment3 = self::factory()->comment->create( array( 'comment_date' => '2016-01-17T00:00:00Z', 'comment_post_ID' => self::$post_id, @@ -1003,7 +1003,7 @@ public function test_get_comment_invalid_context() { public function test_get_comment_invalid_post_id() { wp_set_current_user( 0 ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, @@ -1018,7 +1018,7 @@ public function test_get_comment_invalid_post_id() { public function test_get_comment_invalid_post_id_as_admin() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, @@ -1047,7 +1047,7 @@ public function test_get_comment_not_approved_same_user() { } public function test_get_comment_with_children_link() { - $comment_id_1 = $this->factory->comment->create( + $comment_id_1 = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -1055,7 +1055,7 @@ public function test_get_comment_with_children_link() { ) ); - $child_comment = $this->factory->comment->create( + $child_comment = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_parent' => $comment_id_1, @@ -1071,7 +1071,7 @@ public function test_get_comment_with_children_link() { } public function test_get_comment_without_children_link() { - $comment_id_1 = $this->factory->comment->create( + $comment_id_1 = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -1093,7 +1093,7 @@ public function test_get_comment_with_password_without_edit_post_permission() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); $response = rest_get_server()->dispatch( $request ); @@ -1111,7 +1111,7 @@ public function test_get_comment_with_password_with_valid_password() { 'comment_post_ID' => self::$password_id, ); - $password_comment = $this->factory->comment->create( $args ); + $password_comment = self::factory()->comment->create( $args ); $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); $request->set_param( 'password', 'toomanysecrets' ); @@ -1490,7 +1490,7 @@ public function test_create_item_invalid_date() { public function test_create_item_assign_different_user() { - $subscriber_id = $this->factory->user->create( + $subscriber_id = self::factory()->user->create( array( 'role' => 'subscriber', 'user_email' => 'cbg@androidsdungeon.com', @@ -1521,7 +1521,7 @@ public function test_create_item_assign_different_user() { } public function test_create_comment_without_type() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -1559,7 +1559,7 @@ public function test_create_comment_without_type() { * @ticket 38820 */ public function test_create_comment_with_invalid_type() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -1583,7 +1583,7 @@ public function test_create_comment_with_invalid_type() { } public function test_create_comment_invalid_email() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -1606,7 +1606,7 @@ public function test_create_comment_invalid_email() { } public function test_create_item_current_user() { - $user_id = $this->factory->user->create( + $user_id = self::factory()->user->create( array( 'role' => 'subscriber', 'user_email' => 'lylelanley@example.com', @@ -1728,7 +1728,7 @@ public function test_create_comment_status_without_permission() { } public function test_create_comment_with_status_IP_and_user_agent() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -2006,7 +2006,7 @@ public function test_create_comment_password_post_invalid_permission() { public function test_create_item_duplicate() { wp_set_current_user( self::$subscriber_id ); - $this->factory->comment->create( + self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'Guy N. Cognito', @@ -2031,7 +2031,7 @@ public function test_create_item_duplicate() { } public function test_create_comment_closed() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'comment_status' => 'closed', ) @@ -2303,7 +2303,7 @@ public function test_create_comment_with_password() { } public function test_update_item() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -2347,7 +2347,7 @@ public function test_update_comment_date( $params, $results ) { update_option( 'timezone_string', $params['timezone_string'] ); - $comment_id = $this->factory->comment->create(); + $comment_id = self::factory()->comment->create(); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) ); if ( isset( $params['date'] ) ) { @@ -2374,7 +2374,7 @@ public function test_update_comment_date( $params, $results ) { } public function test_update_item_no_content() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); wp_set_current_user( self::$admin_id ); @@ -2412,7 +2412,7 @@ public function test_update_item_no_change() { public function test_update_comment_status() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 0, 'comment_post_ID' => self::$post_id, @@ -2439,7 +2439,7 @@ public function test_update_comment_status() { public function test_update_comment_field_does_not_use_default_values() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 0, 'comment_post_ID' => self::$post_id, @@ -2720,7 +2720,7 @@ public function test_update_comment_when_can_moderate_comments() { } public function test_update_comment_private_post_invalid_permission() { - $private_comment_id = $this->factory->comment->create( + $private_comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$private_id, @@ -2745,7 +2745,7 @@ public function test_update_comment_private_post_invalid_permission() { public function test_update_comment_with_children_link() { wp_set_current_user( self::$admin_id ); - $comment_id_1 = $this->factory->comment->create( + $comment_id_1 = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -2753,7 +2753,7 @@ public function test_update_comment_with_children_link() { ) ); - $child_comment = $this->factory->comment->create( + $child_comment = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -3047,7 +3047,7 @@ public function test_comment_roundtrip_as_superadmin_unfiltered_html() { public function test_delete_item() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -3067,7 +3067,7 @@ public function test_delete_item() { public function test_delete_item_skip_trash() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -3088,7 +3088,7 @@ public function test_delete_item_skip_trash() { public function test_delete_item_already_trashed() { wp_set_current_user( self::$admin_id ); - $comment_id = $this->factory->comment->create( + $comment_id = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -3123,7 +3123,7 @@ public function test_delete_comment_without_permission() { public function test_delete_child_comment_link() { wp_set_current_user( self::$admin_id ); - $comment_id_1 = $this->factory->comment->create( + $comment_id_1 = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_post_ID' => self::$post_id, @@ -3131,7 +3131,7 @@ public function test_delete_child_comment_link() { ) ); - $child_comment = $this->factory->comment->create( + $child_comment = self::factory()->comment->create( array( 'comment_approved' => 1, 'comment_parent' => $comment_id_1, diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index 40b3dc714e107..a6a9cfa3f46d5 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -51,7 +51,7 @@ public function test_context_param() { $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. - $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -94,13 +94,13 @@ public function test_registered_query_params() { } public function test_get_items() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'draft', 'post_type' => 'page', @@ -114,13 +114,13 @@ public function test_get_items() { } public function test_get_items_parent_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -148,26 +148,26 @@ public function test_get_items_parent_query() { } public function test_get_items_parents_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $id1, ) ); - $id3 = $this->factory->post->create( + $id3 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id4 = $this->factory->post->create( + $id4 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -190,13 +190,13 @@ public function test_get_items_parents_query() { } public function test_get_items_parent_exclude_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -224,27 +224,27 @@ public function test_get_items_parent_exclude_query() { } public function test_get_items_menu_order_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 2, ) ); - $id3 = $this->factory->post->create( + $id3 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 3, ) ); - $id4 = $this->factory->post->create( + $id4 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -302,13 +302,13 @@ public function test_get_items_min_max_pages_query() { public function test_get_items_private_filter_query_var() { // Private query vars inaccessible to unauthorized users. wp_set_current_user( 0 ); - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $draft_id = $this->factory->post->create( + $draft_id = self::factory()->post->create( array( 'post_status' => 'draft', 'post_type' => 'page', @@ -336,19 +336,19 @@ public function test_get_items_invalid_date() { } public function test_get_items_valid_date() { - $post1 = $this->factory->post->create( + $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-15T00:00:00Z', 'post_type' => 'page', ) ); - $post2 = $this->factory->post->create( + $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-16T00:00:00Z', 'post_type' => 'page', ) ); - $post3 = $this->factory->post->create( + $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-17T00:00:00Z', 'post_type' => 'page', @@ -378,19 +378,19 @@ public function test_get_items_invalid_modified_date() { * @ticket 50617 */ public function test_get_items_valid_modified_date() { - $post1 = $this->factory->post->create( + $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-01 00:00:00', 'post_type' => 'page', ) ); - $post2 = $this->factory->post->create( + $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-02 00:00:00', 'post_type' => 'page', ) ); - $post3 = $this->factory->post->create( + $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-03 00:00:00', 'post_type' => 'page', @@ -416,7 +416,7 @@ public function test_get_item() { } public function test_get_item_invalid_post_type() { - $post_id = $this->factory->post->create(); + $post_id = self::factory()->post->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 404, $response->get_status() ); @@ -448,7 +448,7 @@ public function test_create_item_with_template() { } public function test_create_page_with_parent() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'type' => 'page', ) @@ -498,7 +498,7 @@ public function test_update_item() { } public function test_delete_item() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Deleted page', @@ -525,7 +525,7 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { wp_set_current_user( self::$editor_id ); - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -547,7 +547,7 @@ public function test_prepare_item_limit_fields() { } public function test_get_pages_params() { - $this->factory->post->create_many( + self::factory()->post->create_many( 8, array( 'post_type' => 'page', @@ -578,7 +578,7 @@ public function test_get_pages_params() { public function test_update_page_menu_order() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', ) @@ -601,7 +601,7 @@ public function test_update_page_menu_order() { public function test_update_page_menu_order_to_zero() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => 1, @@ -624,12 +624,12 @@ public function test_update_page_menu_order_to_zero() { } public function test_update_page_parent_non_zero() { - $page_id1 = $this->factory->post->create( + $page_id1 = self::factory()->post->create( array( 'post_type' => 'page', ) ); - $page_id2 = $this->factory->post->create( + $page_id2 = self::factory()->post->create( array( 'post_type' => 'page', ) @@ -647,12 +647,12 @@ public function test_update_page_parent_non_zero() { } public function test_update_page_parent_zero() { - $page_id1 = $this->factory->post->create( + $page_id1 = self::factory()->post->create( array( 'post_type' => 'page', ) ); - $page_id2 = $this->factory->post->create( + $page_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1, @@ -671,7 +671,7 @@ public function test_update_page_parent_zero() { } public function test_get_page_with_password() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_password' => '$inthebananastand', @@ -689,7 +689,7 @@ public function test_get_page_with_password() { } public function test_get_page_with_password_using_password() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_password' => '$inthebananastand', @@ -711,7 +711,7 @@ public function test_get_page_with_password_using_password() { } public function test_get_page_with_password_using_incorrect_password() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_password' => '$inthebananastand', @@ -727,7 +727,7 @@ public function test_get_page_with_password_using_incorrect_password() { } public function test_get_page_with_password_without_permission() { - $page_id = $this->factory->post->create( + $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_password' => '$inthebananastand', diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index 85671eff54981..ebce49a7f355c 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -253,7 +253,7 @@ public function set_up() { protected function grant_write_permission() { // Ensure we have write permission. - $user = $this->factory->user->create( + $user = self::factory()->user->create( array( 'role' => 'editor', ) diff --git a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php index 273c4e3916f48..901e8bb35783e 100644 --- a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php @@ -43,7 +43,7 @@ public function test_get_items() { } public function test_get_items_logged_in() { - $user_id = $this->factory->user->create( array( 'role' => 'author' ) ); + $user_id = self::factory()->user->create( array( 'role' => 'author' ) ); wp_set_current_user( $user_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/statuses' ); @@ -72,7 +72,7 @@ public function test_get_items_unauthorized_context() { } public function test_get_item() { - $user_id = $this->factory->user->create( array( 'role' => 'author' ) ); + $user_id = self::factory()->user->create( array( 'role' => 'author' ) ); wp_set_current_user( $user_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' ); $request->set_param( 'context', 'edit' ); @@ -94,7 +94,7 @@ public function test_get_item_invalid_access() { } public function test_get_item_invalid_internal() { - $user_id = $this->factory->user->create(); + $user_id = self::factory()->user->create(); wp_set_current_user( $user_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/inherit' ); diff --git a/tests/phpunit/tests/rest-api/rest-post-types-controller.php b/tests/phpunit/tests/rest-api/rest-post-types-controller.php index 22ff225a69a52..0ab2a7b937005 100644 --- a/tests/phpunit/tests/rest-api/rest-post-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-types-controller.php @@ -94,7 +94,7 @@ public function test_get_item_invalid_type() { } public function test_get_item_edit_context() { - $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); $request->set_param( 'context', 'edit' ); diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 5ef229567b91f..5fa7e3cf98f02 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -273,8 +273,8 @@ public function test_get_items_empty_query() { } public function test_get_items_author_query() { - $this->factory->post->create( array( 'post_author' => self::$editor_id ) ); - $this->factory->post->create( array( 'post_author' => self::$author_id ) ); + self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); + self::factory()->post->create( array( 'post_author' => self::$author_id ) ); $total_posts = self::$total_posts + 2; @@ -305,8 +305,8 @@ public function test_get_items_author_query() { } public function test_get_items_author_exclude_query() { - $this->factory->post->create( array( 'post_author' => self::$editor_id ) ); - $this->factory->post->create( array( 'post_author' => self::$author_id ) ); + self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); + self::factory()->post->create( array( 'post_author' => self::$author_id ) ); $total_posts = self::$total_posts + 2; @@ -347,13 +347,13 @@ public function test_get_items_author_exclude_query() { } public function test_get_items_include_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_date' => '2001-02-03 04:05:06', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_date' => '2001-02-03 04:05:07', @@ -386,19 +386,19 @@ public function test_get_items_include_query() { } public function test_get_items_orderby_author_query() { - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_author' => self::$editor_id, ) ); - $id3 = $this->factory->post->create( + $id3 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_author' => self::$editor_id, ) ); - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_author' => self::$author_id, @@ -421,9 +421,9 @@ public function test_get_items_orderby_author_query() { } public function test_get_items_orderby_modified_query() { - $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $this->update_post_modified( $id1, '2016-04-20 4:26:20' ); $this->update_post_modified( $id2, '2016-02-01 20:24:02' ); @@ -445,19 +445,19 @@ public function test_get_items_orderby_modified_query() { } public function test_get_items_orderby_parent_query() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', ) ); - $id3 = $this->factory->post->create( + $id3 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', @@ -483,8 +483,8 @@ public function test_get_items_orderby_parent_query() { } public function test_get_items_exclude_query() { - $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $response = rest_get_server()->dispatch( $request ); @@ -513,7 +513,7 @@ public function test_get_items_exclude_query() { } public function test_get_items_search_query() { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Search Result', 'post_status' => 'publish', @@ -535,13 +535,13 @@ public function test_get_items_search_query() { } public function test_get_items_slug_query() { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Banana', 'post_status' => 'publish', @@ -558,19 +558,19 @@ public function test_get_items_slug_query() { } public function test_get_items_multiple_slugs_array_query() { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Banana', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Peach', 'post_status' => 'publish', @@ -592,19 +592,19 @@ public function test_get_items_multiple_slugs_array_query() { } public function test_get_items_multiple_slugs_string_query() { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Banana', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Peach', 'post_status' => 'publish', @@ -628,7 +628,7 @@ public function test_get_items_multiple_slugs_string_query() { public function test_get_items_status_query() { wp_set_current_user( 0 ); - $this->factory->post->create( array( 'post_status' => 'draft' ) ); + self::factory()->post->create( array( 'post_status' => 'draft' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); @@ -654,9 +654,9 @@ public function test_get_items_status_query() { public function test_get_items_multiple_statuses_string_query() { wp_set_current_user( self::$editor_id ); - $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $this->factory->post->create( array( 'post_status' => 'private' ) ); - $this->factory->post->create( array( 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_status' => 'draft' ) ); + self::factory()->post->create( array( 'post_status' => 'private' ) ); + self::factory()->post->create( array( 'post_status' => 'publish' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'context', 'edit' ); @@ -677,9 +677,9 @@ public function test_get_items_multiple_statuses_string_query() { public function test_get_items_multiple_statuses_array_query() { wp_set_current_user( self::$editor_id ); - $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $this->factory->post->create( array( 'post_status' => 'pending' ) ); - $this->factory->post->create( array( 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_status' => 'draft' ) ); + self::factory()->post->create( array( 'post_status' => 'pending' ) ); + self::factory()->post->create( array( 'post_status' => 'publish' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'context', 'edit' ); @@ -709,7 +709,7 @@ public function test_get_items_multiple_statuses_one_invalid_query() { * @ticket 43701 */ public function test_get_items_multiple_statuses_custom_role_one_invalid_query() { - $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) ); + $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); wp_set_current_user( self::$private_reader_id ); @@ -730,7 +730,7 @@ public function test_get_items_invalid_status_query() { } public function test_get_items_status_without_permissions() { - $draft_id = $this->factory->post->create( + $draft_id = self::factory()->post->create( array( 'post_status' => 'draft', ) @@ -750,25 +750,25 @@ public function test_get_items_status_without_permissions() { } public function test_get_items_order_and_orderby() { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple Pie', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple Sauce', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple Cobbler', 'post_status' => 'publish', ) ); - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Apple Coffee Cake', 'post_status' => 'publish', @@ -805,7 +805,7 @@ public function test_get_items_order_and_orderby() { } public function test_get_items_with_orderby_include_without_include_param() { - $this->factory->post->create( array( 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_status' => 'publish' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'orderby', 'include' ); @@ -816,19 +816,19 @@ public function test_get_items_with_orderby_include_without_include_param() { } public function test_get_items_with_orderby_id() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_date' => '2016-01-13 02:26:48', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_date' => '2016-01-12 02:26:48', ) ); - $id3 = $this->factory->post->create( + $id3 = self::factory()->post->create( array( 'post_status' => 'publish', 'post_date' => '2016-01-11 02:26:48', @@ -850,14 +850,14 @@ public function test_get_items_with_orderby_id() { } public function test_get_items_with_orderby_slug() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_title' => 'ABC', 'post_name' => 'xyz', 'post_status' => 'publish', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_title' => 'XYZ', 'post_name' => 'abc', @@ -881,7 +881,7 @@ public function test_get_items_with_orderby_slug() { public function test_get_items_with_orderby_slugs() { $slugs = array( 'burrito', 'taco', 'chalupa' ); foreach ( $slugs as $slug ) { - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => $slug, 'post_name' => $slug, @@ -903,14 +903,14 @@ public function test_get_items_with_orderby_slugs() { } public function test_get_items_with_orderby_relevance() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_title' => 'Title is more relevant', 'post_content' => 'Content is', 'post_status' => 'publish', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_title' => 'Title is', 'post_content' => 'Content is less relevant', @@ -931,14 +931,14 @@ public function test_get_items_with_orderby_relevance() { } public function test_get_items_with_orderby_relevance_two_terms() { - $id1 = $this->factory->post->create( + $id1 = self::factory()->post->create( array( 'post_title' => 'Title is more relevant', 'post_content' => 'Content is', 'post_status' => 'publish', ) ); - $id2 = $this->factory->post->create( + $id2 = self::factory()->post->create( array( 'post_title' => 'Title is', 'post_content' => 'Content is less relevant', @@ -1005,9 +1005,9 @@ public function test_get_items_tags_query() { public function test_get_items_tags_exclude_query() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id4 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $tag = wp_insert_term( 'My Tag', 'post_tag' ); $total_posts = self::$total_posts + 3; @@ -1028,7 +1028,7 @@ public function test_get_items_tags_exclude_query() { public function test_get_items_tags_and_categories_query() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $tag = wp_insert_term( 'My Tag', 'post_tag' ); $category = wp_insert_term( 'My Category', 'category' ); @@ -1053,7 +1053,7 @@ public function test_get_items_tags_and_categories_query() { */ public function test_get_items_tags_or_categories_query() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $tag = wp_insert_term( 'My Tag', 'post_tag' ); $category = wp_insert_term( 'My Category', 'category' ); @@ -1075,7 +1075,7 @@ public function test_get_items_tags_or_categories_query() { public function test_get_items_tags_and_categories_exclude_query() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $tag = wp_insert_term( 'My Tag', 'post_tag' ); $category = wp_insert_term( 'My Category', 'category' ); @@ -1102,9 +1102,9 @@ public function test_get_items_tags_and_categories_exclude_query() { */ public function test_get_items_tags_or_categories_exclude_query() { $id1 = end( self::$post_ids ); - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id4 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $tag = wp_insert_term( 'My Tag', 'post_tag' ); $category = wp_insert_term( 'My Category', 'category' ); @@ -1366,7 +1366,7 @@ public function test_get_items_relation_with_no_tax_query() { public function test_get_items_sticky() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); update_option( 'sticky_posts', array( $id2 ) ); @@ -1387,7 +1387,7 @@ public function test_get_items_sticky() { public function test_get_items_sticky_with_include() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); update_option( 'sticky_posts', array( $id2 ) ); @@ -1455,7 +1455,7 @@ public function test_get_items_sticky_with_include_no_sticky_posts() { public function test_get_items_not_sticky() { $id1 = end( self::$post_ids ); - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $total_posts = self::$total_posts + 1; @@ -1477,8 +1477,8 @@ public function test_get_items_not_sticky() { public function test_get_items_not_sticky_with_exclude() { $id1 = end( self::$post_ids ); - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $total_posts = self::$total_posts + 2; @@ -1503,8 +1503,8 @@ public function test_get_items_not_sticky_with_exclude() { public function test_get_items_not_sticky_with_exclude_no_sticky_posts() { $id1 = self::$post_id; - $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $total_posts = self::$total_posts + 2; @@ -1574,7 +1574,7 @@ public function test_get_items_primes_parent_post_caches() { $parent_id2 = self::$post_ids[1]; $parent_ids = array( $parent_id1, $parent_id2 ); $attachment_ids = array(); - $attachment_ids[] = $this->factory->attachment->create_object( + $attachment_ids[] = self::factory()->attachment->create_object( DIR_TESTDATA . '/images/canola.jpg', $parent_id1, array( @@ -1583,7 +1583,7 @@ public function test_get_items_primes_parent_post_caches() { ) ); - $attachment_ids[] = $this->factory->attachment->create_object( + $attachment_ids[] = self::factory()->attachment->create_object( DIR_TESTDATA . '/images/canola.jpg', $parent_id2, array( @@ -1628,7 +1628,7 @@ public function test_get_items_pagination_headers() { $this->assertStringContainsString( '<' . $next_link . '>; rel="next"', $headers['Link'] ); // 3rd page. - $this->factory->post->create(); + self::factory()->post->create(); $total_posts++; $total_pages++; $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); @@ -1707,7 +1707,7 @@ public function test_get_items_pagination_headers() { } public function test_get_items_status_draft_permissions() { - $draft_id = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); // Drafts status query var inaccessible to unauthorized users. wp_set_current_user( 0 ); @@ -1737,7 +1737,7 @@ public function test_get_items_status_draft_permissions() { * @ticket 43701 */ public function test_get_items_status_private_permissions() { - $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) ); + $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) ); wp_set_current_user( 0 ); @@ -1792,9 +1792,9 @@ public function test_get_items_invalid_date() { } public function test_get_items_valid_date() { - $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) ); - $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) ); - $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) ); + $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) ); + $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) ); + $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'after', '2016-01-15T00:00:00Z' ); @@ -1820,9 +1820,9 @@ public function test_get_items_invalid_modified_date() { * @ticket 50617 */ public function test_get_items_valid_modified_date() { - $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) ); - $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) ); - $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) ); + $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) ); + $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) ); + $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) ); $this->update_post_modified( $post1, '2016-01-15 00:00:00' ); $this->update_post_modified( $post2, '2016-01-16 00:00:00' ); $this->update_post_modified( $post3, '2016-01-17 00:00:00' ); @@ -1940,7 +1940,7 @@ public function test_get_item_links_no_author() { } public function test_get_post_draft_status_not_authenticated() { - $draft_id = $this->factory->post->create( + $draft_id = self::factory()->post->create( array( 'post_status' => 'draft', ) @@ -1956,7 +1956,7 @@ public function test_get_post_draft_status_not_authenticated() { public function test_get_post_draft_edit_context() { $post_content = 'Hello World!'; - $this->factory->post->create( + self::factory()->post->create( array( 'post_title' => 'Hola', 'post_password' => 'password', @@ -1965,7 +1965,7 @@ public function test_get_post_draft_edit_context() { 'post_author' => self::$editor_id, ) ); - $draft_id = $this->factory->post->create( + $draft_id = self::factory()->post->create( array( 'post_status' => 'draft', 'post_author' => self::$contributor_id, @@ -2031,7 +2031,7 @@ public function test_get_post_context_without_permission() { } public function test_get_post_with_password() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_password' => '$inthebananastand', ) @@ -2050,7 +2050,7 @@ public function test_get_post_with_password() { } public function test_get_post_with_password_using_password() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_password' => '$inthebananastand', 'post_content' => 'Some secret content.', @@ -2074,7 +2074,7 @@ public function test_get_post_with_password_using_password() { } public function test_get_post_with_password_using_incorrect_password() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_password' => '$inthebananastand', ) @@ -2090,7 +2090,7 @@ public function test_get_post_with_password_using_incorrect_password() { } public function test_get_post_with_password_without_permission() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_password' => '$inthebananastand', 'post_content' => 'Some secret content.', @@ -2114,7 +2114,7 @@ public function test_get_post_with_password_without_permission() { * @ticket 43887 */ public function test_get_post_should_not_have_block_version_when_context_view() { - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '', ) @@ -2134,7 +2134,7 @@ public function test_get_post_should_not_have_block_version_when_context_view() public function test_get_post_should_have_block_version_indicate_block_content_when_context_edit() { wp_set_current_user( self::$editor_id ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '', ) @@ -2155,7 +2155,7 @@ public function test_get_post_should_have_block_version_indicate_block_content_w public function test_get_post_should_have_block_version_indicate_no_block_content_when_context_edit() { wp_set_current_user( self::$editor_id ); - $post_id = $this->factory->post->create( + $post_id = self::factory()->post->create( array( 'post_content' => '