From e70ebea219a3123f42ea7f1ff31081aeb9549563 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 16 Oct 2015 21:04:12 +0000 Subject: [PATCH] Unit Tests: one `$factory` to rule them all, and it shall be `static`. Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`. Replace `$this->factory` with `self::$factory` over 2000 times. Rewrite all of the tests that were hard-coding dynamic values. #YOLOFriday git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase-ajax.php | 4 +- tests/phpunit/includes/testcase-canonical.php | 2 +- tests/phpunit/includes/testcase-xmlrpc.php | 2 +- tests/phpunit/includes/testcase.php | 15 +- tests/phpunit/tests/admin/includesComment.php | 24 +- tests/phpunit/tests/admin/includesPlugin.php | 2 +- tests/phpunit/tests/admin/includesPost.php | 88 +-- tests/phpunit/tests/adminbar.php | 20 +- tests/phpunit/tests/ajax/Autosave.php | 6 +- tests/phpunit/tests/ajax/CustomizeMenus.php | 12 +- tests/phpunit/tests/ajax/DeleteComment.php | 4 +- tests/phpunit/tests/ajax/DimComment.php | 4 +- tests/phpunit/tests/ajax/EditComment.php | 4 +- tests/phpunit/tests/ajax/GetComments.php | 6 +- tests/phpunit/tests/ajax/QuickEdit.php | 6 +- tests/phpunit/tests/ajax/ReplytoComment.php | 6 +- tests/phpunit/tests/attachment/slashes.php | 2 +- tests/phpunit/tests/avatar.php | 8 +- tests/phpunit/tests/canonical/pageOnFront.php | 4 +- tests/phpunit/tests/canonical/paged.php | 2 +- tests/phpunit/tests/category.php | 44 +- .../tests/category/getCategoryParents.php | 8 +- .../tests/category/wpListCategories.php | 48 +- tests/phpunit/tests/comment-submission.php | 60 +- tests/phpunit/tests/comment.php | 48 +- tests/phpunit/tests/comment/checkComment.php | 4 +- tests/phpunit/tests/comment/commentForm.php | 8 +- .../tests/comment/commentsTemplate.php | 112 +-- tests/phpunit/tests/comment/dateQuery.php | 4 +- .../phpunit/tests/comment/getCommentClass.php | 16 +- .../phpunit/tests/comment/getCommentCount.php | 10 +- .../tests/comment/getCommentExcerpt.php | 4 +- .../phpunit/tests/comment/getCommentLink.php | 14 +- .../tests/comment/getCommentsPagesCount.php | 18 +- .../tests/comment/getPageOfComment.php | 80 +-- tests/phpunit/tests/comment/metaCache.php | 24 +- tests/phpunit/tests/comment/query.php | 636 +++++++++--------- tests/phpunit/tests/comment/slashes.php | 14 +- tests/phpunit/tests/comment/template.php | 8 +- tests/phpunit/tests/comment/walker.php | 6 +- .../phpunit/tests/comment/wpCountComments.php | 14 +- tests/phpunit/tests/customize/manager.php | 6 +- .../tests/customize/nav-menu-item-setting.php | 24 +- .../tests/customize/nav-menu-setting.php | 2 +- tests/phpunit/tests/customize/nav-menus.php | 24 +- tests/phpunit/tests/customize/panel.php | 8 +- tests/phpunit/tests/customize/section.php | 8 +- tests/phpunit/tests/customize/setting.php | 4 +- tests/phpunit/tests/customize/widgets.php | 2 +- tests/phpunit/tests/date/query.php | 12 +- tests/phpunit/tests/db.php | 2 +- .../phpunit/tests/formatting/SanitizePost.php | 2 +- .../tests/formatting/WpTrimExcerpt.php | 8 +- tests/phpunit/tests/functions.php | 2 +- tests/phpunit/tests/functions/getArchives.php | 4 +- tests/phpunit/tests/general/archives.php | 2 +- tests/phpunit/tests/includes/factory.php | 2 +- tests/phpunit/tests/link.php | 56 +- .../tests/link/getAdjacentPostLink.php | 30 +- .../tests/link/getNextCommentsLink.php | 4 +- .../tests/link/getPostCommentsFeedLink.php | 20 +- .../tests/link/getPreviousCommentsLink.php | 4 +- tests/phpunit/tests/media.php | 28 +- tests/phpunit/tests/meta.php | 8 +- tests/phpunit/tests/meta/slashes.php | 22 +- tests/phpunit/tests/multisite/bootstrap.php | 8 +- .../phpunit/tests/multisite/getSpaceUsed.php | 8 +- .../tests/multisite/ms-files-rewriting.php | 6 +- tests/phpunit/tests/multisite/network.php | 16 +- tests/phpunit/tests/multisite/site.php | 84 +-- .../tests/multisite/updateBlogDetails.php | 4 +- .../multisite/wpmuValidateUserSignup.php | 4 +- tests/phpunit/tests/oembed/controller.php | 22 +- tests/phpunit/tests/oembed/discovery.php | 8 +- .../phpunit/tests/oembed/getResponseData.php | 28 +- tests/phpunit/tests/oembed/headers.php | 4 +- tests/phpunit/tests/oembed/postEmbedUrl.php | 4 +- tests/phpunit/tests/oembed/template.php | 32 +- tests/phpunit/tests/option/multisite.php | 4 +- tests/phpunit/tests/option/networkOption.php | 6 +- tests/phpunit/tests/option/userSettings.php | 2 +- tests/phpunit/tests/post.php | 70 +- tests/phpunit/tests/post/filtering.php | 10 +- tests/phpunit/tests/post/formats.php | 22 +- tests/phpunit/tests/post/getBodyClass.php | 20 +- tests/phpunit/tests/post/getPages.php | 78 +-- tests/phpunit/tests/post/getPostClass.php | 22 +- .../tests/post/getPostsByAuthorSql.php | 16 +- tests/phpunit/tests/post/listPages.php | 14 +- tests/phpunit/tests/post/meta.php | 2 +- tests/phpunit/tests/post/nav-menu.php | 22 +- tests/phpunit/tests/post/objects.php | 22 +- tests/phpunit/tests/post/output.php | 10 +- tests/phpunit/tests/post/query.php | 42 +- tests/phpunit/tests/post/revisions.php | 18 +- tests/phpunit/tests/post/slashes.php | 6 +- tests/phpunit/tests/post/template.php | 44 +- tests/phpunit/tests/post/wpUniquePostSlug.php | 42 +- tests/phpunit/tests/query.php | 114 ++-- tests/phpunit/tests/query/conditionals.php | 172 ++--- tests/phpunit/tests/query/dateQuery.php | 202 +++--- tests/phpunit/tests/query/isTerm.php | 12 +- tests/phpunit/tests/query/metaQuery.php | 200 +++--- tests/phpunit/tests/query/postStatus.php | 16 +- tests/phpunit/tests/query/results.php | 34 +- tests/phpunit/tests/query/search.php | 18 +- tests/phpunit/tests/query/setupPostdata.php | 58 +- tests/phpunit/tests/query/taxQuery.php | 250 +++---- tests/phpunit/tests/rest-api/rest-server.php | 2 +- tests/phpunit/tests/rewrite.php | 52 +- tests/phpunit/tests/rewrite/numericSlugs.php | 52 +- .../phpunit/tests/rewrite/oldSlugRedirect.php | 4 +- tests/phpunit/tests/taxonomy.php | 58 +- tests/phpunit/tests/term.php | 28 +- tests/phpunit/tests/term/cache.php | 20 +- tests/phpunit/tests/term/categoryExists.php | 24 +- tests/phpunit/tests/term/getEditTermLink.php | 6 +- tests/phpunit/tests/term/getTerm.php | 14 +- tests/phpunit/tests/term/getTermBy.php | 6 +- tests/phpunit/tests/term/getTermField.php | 10 +- tests/phpunit/tests/term/getTermLink.php | 22 +- tests/phpunit/tests/term/getTerms.php | 252 +++---- tests/phpunit/tests/term/isObjectInTerm.php | 38 +- tests/phpunit/tests/term/meta.php | 36 +- tests/phpunit/tests/term/query.php | 40 +- tests/phpunit/tests/term/slashes.php | 4 +- tests/phpunit/tests/term/termExists.php | 30 +- .../term/wpDeleteObjectTermRelationships.php | 10 +- tests/phpunit/tests/term/wpDeleteTerm.php | 4 +- .../phpunit/tests/term/wpGenerateTagCloud.php | 210 +++--- tests/phpunit/tests/term/wpGetObjectTerms.php | 144 ++-- tests/phpunit/tests/term/wpInsertTerm.php | 86 +-- tests/phpunit/tests/term/wpUniqueTermSlug.php | 22 +- tests/phpunit/tests/term/wpUpdateTerm.php | 84 +-- tests/phpunit/tests/url.php | 28 +- tests/phpunit/tests/user.php | 32 +- tests/phpunit/tests/user/author.php | 10 +- tests/phpunit/tests/user/capabilities.php | 134 ++-- tests/phpunit/tests/user/countUsers.php | 32 +- tests/phpunit/tests/user/dateQuery.php | 10 +- tests/phpunit/tests/user/listAuthors.php | 2 +- tests/phpunit/tests/user/mapMetaCap.php | 8 +- tests/phpunit/tests/user/multisite.php | 44 +- tests/phpunit/tests/user/query.php | 40 +- tests/phpunit/tests/user/session.php | 2 +- tests/phpunit/tests/user/slashes.php | 6 +- tests/phpunit/tests/user/updateUserCaches.php | 4 +- tests/phpunit/tests/user/wpDeleteUser.php | 16 +- .../tests/user/wpGetUsersWithNoRole.php | 16 +- tests/phpunit/tests/user/wpSetCurrentUser.php | 10 +- tests/phpunit/tests/widgets.php | 4 +- .../tests/xmlrpc/mt/getRecentPostTitles.php | 4 +- tests/phpunit/tests/xmlrpc/mw/editPost.php | 8 +- tests/phpunit/tests/xmlrpc/mw/getPost.php | 2 +- .../tests/xmlrpc/mw/getRecentPosts.php | 2 +- tests/phpunit/tests/xmlrpc/mw/newPost.php | 2 +- tests/phpunit/tests/xmlrpc/wp/deletePost.php | 4 +- tests/phpunit/tests/xmlrpc/wp/editComment.php | 8 +- tests/phpunit/tests/xmlrpc/wp/editPost.php | 28 +- tests/phpunit/tests/xmlrpc/wp/getComment.php | 2 +- tests/phpunit/tests/xmlrpc/wp/getComments.php | 36 +- tests/phpunit/tests/xmlrpc/wp/getPost.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getPosts.php | 10 +- .../phpunit/tests/xmlrpc/wp/getRevisions.php | 6 +- tests/phpunit/tests/xmlrpc/wp/getTerms.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 2 +- tests/phpunit/tests/xmlrpc/wp/newComment.php | 2 +- tests/phpunit/tests/xmlrpc/wp/newPost.php | 2 +- .../tests/xmlrpc/wp/restoreRevision.php | 4 +- 169 files changed, 2631 insertions(+), 2616 deletions(-) diff --git a/tests/phpunit/includes/testcase-ajax.php b/tests/phpunit/includes/testcase-ajax.php index b415976f21..6296ced04b 100644 --- a/tests/phpunit/includes/testcase-ajax.php +++ b/tests/phpunit/includes/testcase-ajax.php @@ -75,7 +75,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { error_reporting( $this->_error_level & ~E_WARNING ); // Make some posts - $this->factory->post->create_many( 5 ); + self::$factory->post->create_many( 5 ); } /** @@ -148,7 +148,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { */ protected function _setRole( $role ) { $post = $_POST; - $user_id = $this->factory->user->create( array( 'role' => $role ) ); + $user_id = self::$factory->user->create( array( 'role' => $role ) ); wp_set_current_user( $user_id ); $_POST = array_merge($_POST, $post); } diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php index 837456fb44..6470a64d3b 100644 --- a/tests/phpunit/includes/testcase-canonical.php +++ b/tests/phpunit/includes/testcase-canonical.php @@ -49,7 +49,7 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase { wp_set_current_user( self::$author_id ); // Already created by install defaults: - // $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); + // self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); self::$post_ids[] = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) ); self::$post_ids[] = $post_id = $factory->post->create( array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' ) ); diff --git a/tests/phpunit/includes/testcase-xmlrpc.php b/tests/phpunit/includes/testcase-xmlrpc.php index bf0f22aa52..6f69569a80 100644 --- a/tests/phpunit/includes/testcase-xmlrpc.php +++ b/tests/phpunit/includes/testcase-xmlrpc.php @@ -22,7 +22,7 @@ class WP_XMLRPC_UnitTestCase extends WP_UnitTestCase { } protected function make_user_by_role( $role ) { - return $this->factory->user->create( array( + return self::$factory->user->create( array( 'user_login' => $role, 'user_pass' => $role, 'role' => $role diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 0d56cc3e7d..e7c3308a33 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -17,9 +17,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { /** * @var WP_UnitTest_Factory */ - protected $factory; - - protected static $static_factory; + protected static $factory; public static function get_called_class() { if ( function_exists( 'get_called_class' ) ) { @@ -39,16 +37,16 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { public static function setUpBeforeClass() { parent::setUpBeforeClass(); + if ( ! self::$factory ) { + self::$factory = new WP_UnitTest_Factory(); + } + $c = self::get_called_class(); if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { return; } - if ( ! self::$static_factory ) { - self::$static_factory = new WP_UnitTest_Factory(); - } - - call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$static_factory ); + call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$factory ); self::commit_transaction(); } @@ -82,7 +80,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { $wpdb->show_errors = true; $wpdb->db_connect(); ini_set('display_errors', 1 ); - $this->factory = new WP_UnitTest_Factory; $this->clean_up_global_scope(); /* diff --git a/tests/phpunit/tests/admin/includesComment.php b/tests/phpunit/tests/admin/includesComment.php index fe9b86cb72..46f3b11398 100644 --- a/tests/phpunit/tests/admin/includesComment.php +++ b/tests/phpunit/tests/admin/includesComment.php @@ -6,15 +6,15 @@ */ class Tests_Admin_IncludesComment extends WP_UnitTestCase { public function test_must_match_date_and_author() { - $p1 = $this->factory->post->create(); - $c1 = $this->factory->comment->create( array( + $p1 = self::$factory->post->create(); + $c1 = self::$factory->comment->create( array( 'comment_author' => 1, 'comment_date' => '2014-05-06 12:00:00', 'comment_post_ID' => $p1, ) ); - $p2 = $this->factory->post->create(); - $c2 = $this->factory->comment->create( array( + $p2 = self::$factory->post->create(); + $c2 = self::$factory->comment->create( array( 'comment_author' => 2, 'comment_date' => '2004-01-02 12:00:00', 'comment_post_ID' => $p2, @@ -28,8 +28,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase { * @ticket 33871 */ public function test_default_value_of_timezone_should_be_blog() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_author' => 1, 'comment_post_ID' => $p, 'comment_date' => '2014-05-06 12:00:00', @@ -43,8 +43,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase { * @ticket 33871 */ public function test_should_respect_timezone_blog() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_author' => 1, 'comment_post_ID' => $p, 'comment_date' => '2014-05-06 12:00:00', @@ -58,8 +58,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase { * @ticket 33871 */ public function test_should_respect_timezone_gmt() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_author' => 1, 'comment_post_ID' => $p, 'comment_date' => '2014-05-06 12:00:00', @@ -73,8 +73,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase { * @ticket 33871 */ public function test_invalid_timezone_should_fall_back_on_blog() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_author' => 1, 'comment_post_ID' => $p, 'comment_date' => '2014-05-06 12:00:00', diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index ea4971cc5e..a51a92924b 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -29,7 +29,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { function test_menu_page_url() { $current_user = get_current_user_id(); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); update_option( 'siteurl', 'http://example.com' ); // add some pages diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php index aabc69fc55..7fa3dd331f 100644 --- a/tests/phpunit/tests/admin/includesPost.php +++ b/tests/phpunit/tests/admin/includesPost.php @@ -11,8 +11,8 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { } function test__wp_translate_postdata_cap_checks_contributor() { - $contributor_id = $this->factory->user->create( array( 'role' => 'contributor' ) ); - $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) ); + $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $contributor_id ); @@ -51,7 +51,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { // Edit Draft Post for another user $_post_data = array(); - $_post_data['post_ID'] = $this->factory->post->create( array( 'post_author' => $editor_id ) ); + $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $editor_id ) ); $_post_data['post_author'] = $editor_id; $_post_data['post_type'] = 'post'; $_post_data['post_status'] = 'draft'; @@ -64,8 +64,8 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { } function test__wp_translate_postdata_cap_checks_editor() { - $contributor_id = $this->factory->user->create( array( 'role' => 'contributor' ) ); - $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) ); + $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $editor_id ); @@ -104,7 +104,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { // Edit Draft Post for another user $_post_data = array(); - $_post_data['post_ID'] = $this->factory->post->create( array( 'post_author' => $contributor_id ) ); + $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $contributor_id ) ); $_post_data['post_author'] = $contributor_id; $_post_data['post_type'] = 'post'; $_post_data['post_status'] = 'draft'; @@ -122,9 +122,9 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { * @ticket 25272 */ function test_edit_post_auto_draft() { - $user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $user_id ); - $post = $this->factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); + $post = self::$factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); $this->assertEquals( 'auto-draft', $post->post_status ); $post_data = array( 'post_title' => 'Post title', @@ -140,22 +140,22 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { * @ticket 30615 */ public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() { - $u = $this->factory->user->create( array( 'role' => 'editor' ) ); + $u = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $u ); register_taxonomy( 'wptests_tax', array( 'post' ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', 'slug' => 'bar', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'bar', 'slug' => 'foo', ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $post_data = array( 'post_ID' => $p, @@ -179,17 +179,17 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { * @ticket 30615 */ public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() { - $u = $this->factory->user->create( array( 'role' => 'editor' ) ); + $u = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $u ); register_taxonomy( 'wptests_tax', array( 'post' ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', 'slug' => 'bar', ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $post_data = array( 'post_ID' => $p, @@ -209,18 +209,18 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { * @ticket 27792 */ function test_bulk_edit_posts_stomping() { - $admin = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $users = $this->factory->user->create_many( 2, array( 'role' => 'author' ) ); + $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $users = self::$factory->user->create_many( 2, array( 'role' => 'author' ) ); wp_set_current_user( $admin ); - $post1 = $this->factory->post->create( array( + $post1 = self::$factory->post->create( array( 'post_author' => $users[0], 'comment_status' => 'open', 'ping_status' => 'open', 'post_status' => 'publish', ) ); - $post2 = $this->factory->post->create( array( + $post2 = self::$factory->post->create( array( 'post_author' => $users[1], 'comment_status' => 'closed', 'ping_status' => 'closed', @@ -255,7 +255,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { $this->set_permalink_structure( "/$permalink_structure/" ); $future_date = date( 'Y-m-d H:i:s', time() + 100 ); - $p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); + $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); $found = get_sample_permalink( $p ); $expected = trailingslashit( home_url( $permalink_structure ) ); @@ -268,10 +268,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { * @ticket 18306 */ public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $future_date = date( 'Y-m-d H:i:s', time() + 100 ); - $p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); + $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); $found = get_sample_permalink_html( $p ); $this->assertContains( 'href="' . get_option( 'home' ) . '/?p=' . $p . '"', $found ); @@ -284,10 +284,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() { $this->set_permalink_structure( '/%postname%/' ); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $future_date = date( 'Y-m-d H:i:s', time() + 100 ); - $p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); + $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); $found = get_sample_permalink_html( $p ); $post = get_post( $p ); @@ -301,10 +301,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() { $this->set_permalink_structure( '/%postname%/' ); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); // Published posts should use published permalink - $p = $this->factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); + $p = self::$factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); $found = get_sample_permalink_html( $p, null, 'new_slug' ); $post = get_post( $p ); @@ -313,7 +313,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { // Scheduled posts should use published permalink $future_date = date( 'Y-m-d H:i:s', time() + 100 ); - $p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); + $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); $found = get_sample_permalink_html( $p, null, 'new_slug' ); $post = get_post( $p ); @@ -321,7 +321,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { $this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message ); // Draft posts should use preview link - $p = $this->factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); + $p = self::$factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); $found = get_sample_permalink_html( $p, null, 'new_slug' ); $post = get_post( $p ); @@ -339,7 +339,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() { $this->set_permalink_structure( '/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '2015', ) ); @@ -353,7 +353,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '2015', ) ); @@ -367,7 +367,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '11', ) ); @@ -381,7 +381,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '13', ) ); @@ -395,7 +395,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '30', ) ); @@ -409,11 +409,11 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $this->factory->post->create( array( + self::$factory->post->create( array( 'post_name' => '30-2', ) ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '30', ) ); @@ -427,7 +427,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '32', ) ); @@ -441,7 +441,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { $this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_name' => '30', ) ); @@ -450,7 +450,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { } public function test_post_exists_should_match_title() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => 'Foo Bar', ) ); @@ -458,7 +458,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { } public function test_post_exists_should_not_match_nonexistent_title() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => 'Foo Bar', ) ); @@ -468,7 +468,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_post_exists_should_match_nonempty_content() { $title = 'Foo Bar'; $content = 'Foo Bar Baz'; - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => $title, 'post_content' => $content, ) ); @@ -479,7 +479,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() { $title = 'Foo Bar'; $content = 'Foo Bar Baz'; - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => $title, 'post_content' => $content . ' Quz', ) ); @@ -490,7 +490,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_post_exists_should_match_nonempty_date() { $title = 'Foo Bar'; $date = '2014-05-08 12:00:00'; - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => $title, 'post_date' => $date, ) ); @@ -501,7 +501,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() { $title = 'Foo Bar'; $date = '2014-05-08 12:00:00'; - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => $title, 'post_date' => '2015-10-10 00:00:00', ) ); @@ -513,7 +513,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase { $title = 'Foo Bar'; $content = 'Foo Bar Baz'; $date = '2014-05-08 12:00:00'; - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_title' => $title, 'post_content' => $content, 'post_date' => $date, diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 299323790b..0ef664775a 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -15,7 +15,7 @@ class Tests_AdminBar extends WP_UnitTestCase { * @ticket 21117 */ function test_content_post_type() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) ); register_post_type( 'content', array( 'show_in_admin_bar' => true ) ); @@ -34,7 +34,7 @@ class Tests_AdminBar extends WP_UnitTestCase { * @ticket 21117 */ function test_merging_existing_meta_values() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) ); $admin_bar = new WP_Admin_Bar; @@ -62,7 +62,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->markTestSkipped( 'Test does not run in multisite' ); } - $nobody = $this->factory->user->create( array( 'role' => '' ) ); + $nobody = self::$factory->user->create( array( 'role' => '' ) ); $this->assertFalse( user_can( $nobody, 'read' ) ); wp_set_current_user( $nobody ); @@ -92,7 +92,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->markTestSkipped( 'Test does not run in multisite' ); } - $editor = $this->factory->user->create( array( 'role' => 'editor' ) ); + $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->assertTrue( user_can( $editor, 'read' ) ); wp_set_current_user( $editor ); @@ -125,13 +125,13 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->markTestSkipped( 'Test only runs in multisite' ); } - $admin = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $editor = $this->factory->user->create( array( 'role' => 'editor' ) ); + $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->assertTrue( user_can( $admin, 'read' ) ); $this->assertTrue( user_can( $editor, 'read' ) ); - $new_blog_id = $this->factory->blog->create( array( + $new_blog_id = self::$factory->blog->create( array( 'user_id' => $admin, ) ); @@ -179,13 +179,13 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->markTestSkipped( 'Test only runs in multisite' ); } - $admin = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $nobody = $this->factory->user->create( array( 'role' => '' ) ); + $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $nobody = self::$factory->user->create( array( 'role' => '' ) ); $this->assertTrue( user_can( $admin, 'read' ) ); $this->assertFalse( user_can( $nobody, 'read' ) ); - $new_blog_id = $this->factory->blog->create( array( + $new_blog_id = self::$factory->blog->create( array( 'user_id' => $admin, ) ); diff --git a/tests/phpunit/tests/ajax/Autosave.php b/tests/phpunit/tests/ajax/Autosave.php index 33cd79f1ba..aac9274f01 100644 --- a/tests/phpunit/tests/ajax/Autosave.php +++ b/tests/phpunit/tests/ajax/Autosave.php @@ -33,10 +33,10 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { public function setUp() { parent::setUp(); // Set a user so the $post has 'post_author' - $this->user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $this->user_id ); - $post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); $this->_post = get_post( $post_id ); } @@ -97,7 +97,7 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { */ public function test_autosave_locked_post() { // Lock the post to another user - $another_user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $another_user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $another_user_id ); wp_set_post_lock( $this->_post->ID ); diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php index eb0fb3b9dd..94fc646078 100644 --- a/tests/phpunit/tests/ajax/CustomizeMenus.php +++ b/tests/phpunit/tests/ajax/CustomizeMenus.php @@ -22,7 +22,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { public function setUp() { parent::setUp(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; $this->wp_customize = new WP_Customize_Manager(); $wp_customize = $this->wp_customize; @@ -65,7 +65,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->setExpectedException( 'WPAjaxDieStopException' ); } - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) ); $_POST = array( 'action' => 'load-available-menu-items-customizer', @@ -307,8 +307,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { ); // Create some terms and pages. - $this->factory->term->create_many( 5 ); - $this->factory->post->create_many( 5, array( 'post_type' => 'page' ) ); + self::$factory->term->create_many( 5 ); + self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) ); $_POST = array_merge( array( 'action' => 'load-available-menu-items-customizer', @@ -396,7 +396,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->setExpectedException( 'WPAjaxDieStopException' ); } - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) ); $_POST = array( 'action' => 'search-available-menu-items-customizer', @@ -469,7 +469,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { */ function test_ajax_search_available_items_results( $post_args, $expected_results ) { - $this->factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) ); + self::$factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) ); $_POST = array_merge( array( 'action' => 'search-available-menu-items-customizer', diff --git a/tests/phpunit/tests/ajax/DeleteComment.php b/tests/phpunit/tests/ajax/DeleteComment.php index a7a1597498..8b3282acc6 100644 --- a/tests/phpunit/tests/ajax/DeleteComment.php +++ b/tests/phpunit/tests/ajax/DeleteComment.php @@ -26,8 +26,8 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { */ public function setUp() { parent::setUp(); - $post_id = $this->factory->post->create(); - $this->_comments = $this->factory->comment->create_post_comments( $post_id, 15 ); + $post_id = self::$factory->post->create(); + $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 ); $this->_comments = array_map( 'get_comment', $this->_comments ); } diff --git a/tests/phpunit/tests/ajax/DimComment.php b/tests/phpunit/tests/ajax/DimComment.php index d34b64d852..9795f7b578 100644 --- a/tests/phpunit/tests/ajax/DimComment.php +++ b/tests/phpunit/tests/ajax/DimComment.php @@ -26,8 +26,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { */ public function setUp() { parent::setUp(); - $post_id = $this->factory->post->create(); - $this->_comments = $this->factory->comment->create_post_comments( $post_id, 15 ); + $post_id = self::$factory->post->create(); + $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 ); $this->_comments = array_map( 'get_comment', $this->_comments ); } diff --git a/tests/phpunit/tests/ajax/EditComment.php b/tests/phpunit/tests/ajax/EditComment.php index 5d82229e70..b29690df7a 100644 --- a/tests/phpunit/tests/ajax/EditComment.php +++ b/tests/phpunit/tests/ajax/EditComment.php @@ -26,8 +26,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { */ public function setUp() { parent::setUp(); - $post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id, 5 ); + $post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id, 5 ); $this->_comment_post = get_post( $post_id ); } diff --git a/tests/phpunit/tests/ajax/GetComments.php b/tests/phpunit/tests/ajax/GetComments.php index 3e3a3896e3..3702b0bc6d 100644 --- a/tests/phpunit/tests/ajax/GetComments.php +++ b/tests/phpunit/tests/ajax/GetComments.php @@ -32,11 +32,11 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { */ public function setUp() { parent::setUp(); - $post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id, 5 ); + $post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id, 5 ); $this->_comment_post = get_post( $post_id ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->_no_comment_post = get_post( $post_id ); unset( $GLOBALS['post_id'] ); diff --git a/tests/phpunit/tests/ajax/QuickEdit.php b/tests/phpunit/tests/ajax/QuickEdit.php index ec37c5795d..a7ce874196 100644 --- a/tests/phpunit/tests/ajax/QuickEdit.php +++ b/tests/phpunit/tests/ajax/QuickEdit.php @@ -25,17 +25,17 @@ class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase { 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_1', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_2', ) ); // Become an administrator. $this->_setRole( 'administrator' ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_author' => get_current_user_id(), ) ); diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php index 4d07720c89..98e7965d5c 100644 --- a/tests/phpunit/tests/ajax/ReplytoComment.php +++ b/tests/phpunit/tests/ajax/ReplytoComment.php @@ -32,11 +32,11 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { */ public function setUp() { parent::setUp(); - $post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id, 5 ); + $post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id, 5 ); $this->_comment_post = get_post( $post_id ); - $post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); $this->_draft_post = get_post( $post_id ); } diff --git a/tests/phpunit/tests/attachment/slashes.php b/tests/phpunit/tests/attachment/slashes.php index 4be5824565..b44d5a94a0 100644 --- a/tests/phpunit/tests/attachment/slashes.php +++ b/tests/phpunit/tests/attachment/slashes.php @@ -8,7 +8,7 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); diff --git a/tests/phpunit/tests/avatar.php b/tests/phpunit/tests/avatar.php index 5b35fe45aa..7475e45082 100644 --- a/tests/phpunit/tests/avatar.php +++ b/tests/phpunit/tests/avatar.php @@ -87,12 +87,12 @@ class Tests_Avatar extends WP_UnitTestCase { $url2 = get_avatar_url( $user ); $this->assertEquals( $url, $url2 ); - $post_id = $this->factory->post->create( array( 'post_author' => 1 ) ); + $post_id = self::$factory->post->create( array( 'post_author' => 1 ) ); $post = get_post( $post_id ); $url2 = get_avatar_url( $post ); $this->assertEquals( $url, $url2 ); - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) ); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) ); $comment = get_comment( $comment_id ); $url2 = get_avatar_url( $comment ); $this->assertEquals( $url, $url2 ); @@ -138,8 +138,8 @@ class Tests_Avatar extends WP_UnitTestCase { public function test_get_avatar_comment_types_filter() { $url = get_avatar_url( 1 ); - $post_id = $this->factory->post->create( array( 'post_author' => 1 ) ); - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) ); + $post_id = self::$factory->post->create( array( 'post_author' => 1 ) ); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) ); $comment = get_comment( $comment_id ); $url2 = get_avatar_url( $comment ); diff --git a/tests/phpunit/tests/canonical/pageOnFront.php b/tests/phpunit/tests/canonical/pageOnFront.php index a07049de3d..53afc8ca3a 100644 --- a/tests/phpunit/tests/canonical/pageOnFront.php +++ b/tests/phpunit/tests/canonical/pageOnFront.php @@ -18,8 +18,8 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase { parent::setUp(); update_option( 'show_on_front', 'page' ); - update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) ); - update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) ); + update_option( 'page_for_posts', self::$factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) ); + update_option( 'page_on_front', self::$factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) ); } /** diff --git a/tests/phpunit/tests/canonical/paged.php b/tests/phpunit/tests/canonical/paged.php index 1239f4c883..f734f40300 100644 --- a/tests/phpunit/tests/canonical/paged.php +++ b/tests/phpunit/tests/canonical/paged.php @@ -12,7 +12,7 @@ class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { This is a paragraph.'; $next = ''; - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => "{$para}{$next}{$para}{$next}{$para}" ) ); diff --git a/tests/phpunit/tests/category.php b/tests/phpunit/tests/category.php index 85cdf0aadf..613e6d5f95 100644 --- a/tests/phpunit/tests/category.php +++ b/tests/phpunit/tests/category.php @@ -21,7 +21,7 @@ class Tests_Category extends WP_UnitTestCase { */ function test_get_all_category_ids() { // create categories - $this->factory->category->create_many( 2 ); + self::$factory->category->create_many( 2 ); // create new taxonomy to ensure not included register_taxonomy( 'test_tax_cat', 'post' ); @@ -38,13 +38,13 @@ class Tests_Category extends WP_UnitTestCase { function test_get_category_by_slug() { // create Test Categories - $testcat = $this->factory->category->create_and_get( + $testcat = self::$factory->category->create_and_get( array( 'slug' => 'testcat', 'name' => 'Test Category 1' ) ); - $testcat2 = $this->factory->category->create_and_get( + $testcat2 = self::$factory->category->create_and_get( array( 'slug' => 'testcat2', 'name' => 'Test Category 2' @@ -73,7 +73,7 @@ class Tests_Category extends WP_UnitTestCase { 'name' => 'Test MCC', 'description' => 'Category Test' ); - $testcat = $this->factory->category->create_and_get( $testcat_array ); + $testcat = self::$factory->category->create_and_get( $testcat_array ); $testcat_array['term_id'] = $testcat->term_id; $testcat2_array = array( @@ -82,7 +82,7 @@ class Tests_Category extends WP_UnitTestCase { 'description' => 'Category Test', 'parent' => $testcat->term_id ); - $testcat2 = $this->factory->category->create_and_get( $testcat2_array ); + $testcat2 = self::$factory->category->create_and_get( $testcat2_array ); $testcat2_array['term_id'] = $testcat2->term_id; // unset properties to enable validation of object @@ -145,7 +145,7 @@ class Tests_Category extends WP_UnitTestCase { function test_get_cat_name() { // create Test Category - $testcat = $this->factory->category->create_and_get( + $testcat = self::$factory->category->create_and_get( array( 'slug' => 'testcat', 'name' => 'Test Category 1' @@ -165,7 +165,7 @@ class Tests_Category extends WP_UnitTestCase { function test_get_cat_ID() { // create Test Category - $testcat = $this->factory->category->create_and_get( + $testcat = self::$factory->category->create_and_get( array( 'slug' => 'testcat', 'name' => 'Test Category 1' @@ -185,42 +185,42 @@ class Tests_Category extends WP_UnitTestCase { function test_get_category_by_path() { // create Test Categories - $root_id = $this->factory->category->create( + $root_id = self::$factory->category->create( array( 'slug' => 'root', ) ); - $root_cat_id = $this->factory->category->create( + $root_cat_id = self::$factory->category->create( array( 'slug' => 'cat', 'parent' => $root_id ) ); - $root_cat_cat_id = $this->factory->category->create( + $root_cat_cat_id = self::$factory->category->create( array( 'slug' => 'cat', //note this is modified on create 'parent' => $root_cat_id ) ); - $root_path_id = $this->factory->category->create( + $root_path_id = self::$factory->category->create( array( 'slug' => 'path', 'parent' => $root_id ) ); - $root_path_cat_id = $this->factory->category->create( + $root_path_cat_id = self::$factory->category->create( array( 'slug' => 'cat', //note this is modified on create 'parent' => $root_path_id ) ); - $root_level_id = $this->factory->category->create( + $root_level_id = self::$factory->category->create( array( 'slug' => 'level-1', 'parent' => $root_id ) ); - $root_level_cat_id = $this->factory->category->create( + $root_level_cat_id = self::$factory->category->create( array( 'slug' => 'cat', //note this is modified on create 'parent' => $root_level_id @@ -248,7 +248,7 @@ class Tests_Category extends WP_UnitTestCase { */ public function test_wp_dropdown_categories_value_field_should_default_to_term_id() { // Create a test category. - $cat_id = $this->factory->category->create( array( + $cat_id = self::$factory->category->create( array( 'name' => 'Test Category', 'slug' => 'test_category', ) ); @@ -268,7 +268,7 @@ class Tests_Category extends WP_UnitTestCase { */ public function test_wp_dropdown_categories_value_field_term_id() { // Create a test category. - $cat_id = $this->factory->category->create( array( + $cat_id = self::$factory->category->create( array( 'name' => 'Test Category', 'slug' => 'test_category', ) ); @@ -289,7 +289,7 @@ class Tests_Category extends WP_UnitTestCase { */ public function test_wp_dropdown_categories_value_field_slug() { // Create a test category. - $cat_id = $this->factory->category->create( array( + $cat_id = self::$factory->category->create( array( 'name' => 'Test Category', 'slug' => 'test_category', ) ); @@ -310,7 +310,7 @@ class Tests_Category extends WP_UnitTestCase { */ public function test_wp_dropdown_categories_value_field_should_fall_back_on_term_id_when_an_invalid_value_is_provided() { // Create a test category. - $cat_id = $this->factory->category->create( array( + $cat_id = self::$factory->category->create( array( 'name' => 'Test Category', 'slug' => 'test_category', ) ); @@ -330,12 +330,12 @@ class Tests_Category extends WP_UnitTestCase { * @ticket 32330 */ public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() { - $c1 = $this->factory->category->create( array( + $c1 = self::$factory->category->create( array( 'name' => 'Test Category 1', 'slug' => 'test_category_1', ) ); - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'name' => 'Test Category 2', 'slug' => 'test_category_2', ) ); @@ -354,7 +354,7 @@ class Tests_Category extends WP_UnitTestCase { * @ticket 33452 */ public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_no_selected_value_is_explicitly_passed_and_value_field_does_not_have_string_values() { - $cats = $this->factory->category->create_many( 3 ); + $cats = self::$factory->category->create_many( 3 ); $found = wp_dropdown_categories( array( 'echo' => 0, @@ -375,7 +375,7 @@ class Tests_Category extends WP_UnitTestCase { * @ticket 33452 */ public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_selected_value_of_0_string_is_explicitly_passed_and_value_field_does_not_have_string_values() { - $cats = $this->factory->category->create_many( 3 ); + $cats = self::$factory->category->create_many( 3 ); $found = wp_dropdown_categories( array( 'echo' => 0, diff --git a/tests/phpunit/tests/category/getCategoryParents.php b/tests/phpunit/tests/category/getCategoryParents.php index c8cc1b9159..b9c6998179 100644 --- a/tests/phpunit/tests/category/getCategoryParents.php +++ b/tests/phpunit/tests/category/getCategoryParents.php @@ -10,8 +10,8 @@ class Tests_Category_GetCategoryParents extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->c1 = $this->factory->category->create_and_get(); - $this->c2 = $this->factory->category->create_and_get( array( + $this->c1 = self::$factory->category->create_and_get(); + $this->c2 = self::$factory->category->create_and_get( array( 'parent' => $this->c1->term_id, ) ); } @@ -51,10 +51,10 @@ class Tests_Category_GetCategoryParents extends WP_UnitTestCase { } public function test_visited() { - $c3 = $this->factory->category->create_and_get( array( + $c3 = self::$factory->category->create_and_get( array( 'parent' => $this->c2->term_id, ) ); - $c4 = $this->factory->category->create_and_get( array( + $c4 = self::$factory->category->create_and_get( array( 'parent' => $c3->term_id, ) ); diff --git a/tests/phpunit/tests/category/wpListCategories.php b/tests/phpunit/tests/category/wpListCategories.php index 91031a667f..0a49f0f832 100644 --- a/tests/phpunit/tests/category/wpListCategories.php +++ b/tests/phpunit/tests/category/wpListCategories.php @@ -5,7 +5,7 @@ */ class Tests_Category_WpListCategories extends WP_UnitTestCase { public function test_class() { - $c = $this->factory->category->create(); + $c = self::$factory->category->create(); $found = wp_list_categories( array( 'hide_empty' => false, @@ -16,8 +16,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { } public function test_class_containing_current_cat() { - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create(); + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create(); $found = wp_list_categories( array( 'hide_empty' => false, @@ -30,8 +30,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { } public function test_class_containing_current_cat_parent() { - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'parent' => $c1, ) ); @@ -49,7 +49,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { * @ticket 33565 */ public function test_current_category_should_accept_an_array_of_ids() { - $cats = $this->factory->category->create_many( 3 ); + $cats = self::$factory->category->create_many( 3 ); $found = wp_list_categories( array( 'echo' => false, @@ -66,10 +66,10 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { * @ticket 16792 */ public function test_should_not_create_element_when_cat_name_is_filtered_to_empty_string() { - $c1 = $this->factory->category->create( array( + $c1 = self::$factory->category->create( array( 'name' => 'Test Cat 1', ) ); - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'name' => 'Test Cat 2', ) ); @@ -88,7 +88,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { } public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() { - $cats = $this->factory->category->create_many( 2 ); + $cats = self::$factory->category->create_many( 2 ); $found = wp_list_categories( array( 'echo' => false, @@ -101,8 +101,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { } public function test_show_option_all_link_should_respect_page_for_posts() { - $cats = $this->factory->category->create_many( 2 ); - $p = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $cats = self::$factory->category->create_many( 2 ); + $p = self::$factory->post->create( array( 'post_type' => 'page' ) ); update_option( 'show_on_front', 'page' ); update_option( 'page_for_posts', $p ); @@ -125,7 +125,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); @@ -149,7 +149,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); @@ -170,7 +170,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); @@ -191,7 +191,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { register_post_type( 'wptests_pt2', array( 'has_archive' => false ) ); register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); @@ -254,7 +254,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { * @ticket 33460 */ public function test_hide_title_if_empty_should_be_ignored_when_category_list_is_not_empty() { - $cat = $this->factory->category->create(); + $cat = self::$factory->category->create(); $found = wp_list_categories( array( 'echo' => false, @@ -269,9 +269,9 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { * @ticket 12981 */ public function test_exclude_tree_should_be_respected() { - $c = $this->factory->category->create(); - $parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); - $child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); + $c = self::$factory->category->create(); + $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); + $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent ); @@ -286,11 +286,11 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { * @ticket 12981 */ public function test_exclude_tree_should_be_merged_with_exclude() { - $c = $this->factory->category->create(); - $parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); - $child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); - $parent2 = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) ); - $child2 = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) ); + $c = self::$factory->category->create(); + $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); + $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); + $parent2 = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) ); + $child2 = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) ); $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent ); diff --git a/tests/phpunit/tests/comment-submission.php b/tests/phpunit/tests/comment-submission.php index cbf0125f97..1fed4f4c9f 100644 --- a/tests/phpunit/tests/comment-submission.php +++ b/tests/phpunit/tests/comment-submission.php @@ -38,7 +38,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertSame( 0, did_action( $error ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'comment_status' => 'closed', ) ); $data = array( @@ -58,7 +58,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertSame( 0, did_action( $error ) ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); wp_trash_post( $post ); $data = array( 'comment_post_ID' => $post->ID, @@ -77,7 +77,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertSame( 0, did_action( $error ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'draft', ) ); $data = array( @@ -98,7 +98,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertSame( 0, did_action( $error ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_date' => date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ), ) ); @@ -121,7 +121,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertSame( 0, did_action( $error ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_password' => 'password', ) ); $data = array( @@ -142,7 +142,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $_COOKIE['wp-postpass_' . COOKIEHASH] = $hasher->HashPassword( $password ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_password' => $password, ) ); $data = array( @@ -162,13 +162,13 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_submitting_valid_comment_as_logged_in_user_succeeds() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'user_url' => 'http://user.example.org' ) ); wp_set_current_user( $user->ID ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment', @@ -187,7 +187,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_submitting_valid_comment_anonymously_succeeds() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment', @@ -214,7 +214,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { */ public function test_submitting_comment_handles_slashes_correctly_handles_slashes() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment with 1 slash: \\', @@ -236,7 +236,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $error = 'not_logged_in'; - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'private', ) ); $data = array( @@ -252,11 +252,11 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_submitting_comment_to_own_private_post_succeeds() { - $user = $this->factory->user->create_and_get(); + $user = self::$factory->user->create_and_get(); wp_set_current_user( $user->ID ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'private', 'post_author' => $user->ID, ) ); @@ -274,16 +274,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_submitting_comment_to_accessible_private_post_succeeds() { - $author = $this->factory->user->create_and_get( array( + $author = self::$factory->user->create_and_get( array( 'role' => 'author', ) ); - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'role' => 'editor', ) ); wp_set_current_user( $user->ID ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'private', 'post_author' => $author->ID, ) ); @@ -301,7 +301,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_anonymous_user_cannot_comment_unfiltered_html() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment ', @@ -318,14 +318,14 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_unprivileged_user_cannot_comment_unfiltered_html() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'role' => 'author', ) ); wp_set_current_user( $user->ID ); $this->assertFalse( current_user_can( 'unfiltered_html' ) ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment ', @@ -340,14 +340,14 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'role' => 'author', ) ); wp_set_current_user( $user->ID ); $this->assertFalse( current_user_can( 'unfiltered_html' ) ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $action = 'unfiltered-html-comment_' . $post->ID; $nonce = wp_create_nonce( $action ); @@ -370,7 +370,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) ); - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'role' => 'editor', ) ); @@ -384,7 +384,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertTrue( current_user_can( 'unfiltered_html' ) ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $action = 'unfiltered-html-comment_' . $post->ID; $nonce = wp_create_nonce( $action ); @@ -405,7 +405,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'role' => 'editor', ) ); @@ -419,7 +419,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertTrue( current_user_can( 'unfiltered_html' ) ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment ', @@ -439,7 +439,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $_comment_registration = get_option( 'comment_registration' ); update_option( 'comment_registration', '1' ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, ); @@ -459,7 +459,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $_require_name_email = get_option( 'require_name_email' ); update_option( 'require_name_email', '1' ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment', @@ -481,7 +481,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $_require_name_email = get_option( 'require_name_email' ); update_option( 'require_name_email', '1' ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment', @@ -503,7 +503,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $_require_name_email = get_option( 'require_name_email' ); update_option( 'require_name_email', '1' ); - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => 'Comment', @@ -523,7 +523,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $error = 'require_valid_comment'; - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = array( 'comment_post_ID' => $post->ID, 'comment' => '', diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index 5c70c77c56..a059149196 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -21,9 +21,9 @@ class Tests_Comment extends WP_UnitTestCase { } function test_wp_update_comment() { - $post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) ); - $post2 = $this->factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) ); - $comments = $this->factory->comment->create_post_comments( $post->ID, 5 ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) ); + $post2 = self::$factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) ); + $comments = self::$factory->comment->create_post_comments( $post->ID, 5 ); $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) ); $this->assertEquals( 1, $result ); $comment = get_comment( $comments[0] ); @@ -39,7 +39,7 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 30627 */ function test_wp_update_comment_updates_comment_type() { - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) ); @@ -51,7 +51,7 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 30307 */ function test_wp_update_comment_updates_user_id() { - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1 ) ); @@ -60,25 +60,25 @@ class Tests_Comment extends WP_UnitTestCase { } public function test_get_approved_comments() { - $ca1 = $this->factory->comment->create( array( + $ca1 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); - $ca2 = $this->factory->comment->create( array( + $ca2 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); - $ca3 = $this->factory->comment->create( array( + $ca3 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); @@ -92,7 +92,7 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 30412 */ public function test_get_approved_comments_with_post_id_0_should_return_empty_array() { - $ca1 = $this->factory->comment->create( array( + $ca1 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); @@ -256,11 +256,11 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 32566 */ public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_author' => 0, ) ); - $c = $this->factory->comment->create( array( + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p, ) ); @@ -271,7 +271,7 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 33587 */ public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { - $c = $this->factory->comment->create( array( + $c = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'spam', ) ); @@ -284,7 +284,7 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 12431 */ public function test_wp_new_comment_with_meta() { - $c = $this->factory->comment->create( array( + $c = self::$factory->comment->create( array( 'comment_approved' => '1', 'comment_meta' => array( 'food' => 'taco', @@ -299,35 +299,35 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 8071 */ public function test_wp_comment_get_children_should_fill_children() { - $c1 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c2, ) ); - $c4 = $this->factory->comment->create( array( + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c5 = $this->factory->comment->create( array( + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); - $c6 = $this->factory->comment->create( array( + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c5, @@ -347,7 +347,7 @@ class Tests_Comment extends WP_UnitTestCase { * @group 27571 */ public function test_post_properties_should_be_lazyloaded() { - $c = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); + $c = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); $post = get_post( self::$post_id ); $comment = get_comment( $c ); diff --git a/tests/phpunit/tests/comment/checkComment.php b/tests/phpunit/tests/comment/checkComment.php index 702e903838..40bca3ac29 100644 --- a/tests/phpunit/tests/comment/checkComment.php +++ b/tests/phpunit/tests/comment/checkComment.php @@ -31,7 +31,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase { } public function test_should_return_true_when_comment_whitelist_is_enabled_and_author_has_approved_comment() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $prev_args = array( 'comment_post_ID' => $post_id, 'comment_content' => 'Can we build it?', @@ -39,7 +39,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase { 'comment_author_email' => 'bob@example.com', 'comment_author' => 'BobtheBuilder', ); - $prev_comment_id = $this->factory->comment->create( $prev_args ); + $prev_comment_id = self::$factory->comment->create( $prev_args ); update_option( 'comment_whitelist', 1 ); diff --git a/tests/phpunit/tests/comment/commentForm.php b/tests/phpunit/tests/comment/commentForm.php index 5573ebdb42..bd91dbffbd 100644 --- a/tests/phpunit/tests/comment/commentForm.php +++ b/tests/phpunit/tests/comment/commentForm.php @@ -5,7 +5,7 @@ */ class Tests_Comment_CommentForm extends WP_UnitTestCase { public function test_default_markup_for_submit_button_and_wrapper() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $args = array( 'name_submit' => 'foo-name', @@ -21,7 +21,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { } public function test_custom_submit_button() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $args = array( 'name_submit' => 'foo-name', @@ -37,7 +37,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { } public function test_custom_submit_field() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $args = array( 'name_submit' => 'foo-name', @@ -57,7 +57,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { * @ticket 32312 */ public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $args = array( 'name_submit' => 'foo-name', diff --git a/tests/phpunit/tests/comment/commentsTemplate.php b/tests/phpunit/tests/comment/commentsTemplate.php index a63f4b2fb2..31f7cbfd1a 100644 --- a/tests/phpunit/tests/comment/commentsTemplate.php +++ b/tests/phpunit/tests/comment/commentsTemplate.php @@ -12,13 +12,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), @@ -42,13 +42,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), @@ -72,13 +72,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), @@ -102,13 +102,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), @@ -132,33 +132,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest_on_subsequent_pages() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), ) ); - $comment_5 = $this->factory->comment->create( array( + $comment_5 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), ) ); - $comment_6 = $this->factory->comment->create( array( + $comment_6 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), @@ -187,33 +187,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), ) ); - $comment_5 = $this->factory->comment->create( array( + $comment_5 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), ) ); - $comment_6 = $this->factory->comment->create( array( + $comment_6 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), @@ -242,23 +242,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), @@ -287,23 +287,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest_on_subsequent_pages() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), @@ -334,18 +334,18 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_last_page_of_comments_should_be_full_when_default_comment_page_is_newest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), @@ -376,18 +376,18 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_first_page_of_comments_should_have_remainder_when_default_comments_page_is_newest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), @@ -416,23 +416,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_oldest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), @@ -480,33 +480,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { */ public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_newest() { $now = time(); - $p = $this->factory->post->create(); - $comment_1 = $this->factory->comment->create( array( + $p = self::$factory->post->create(); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $comment_2 = $this->factory->comment->create( array( + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $comment_3 = $this->factory->comment->create( array( + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $comment_4 = $this->factory->comment->create( array( + $comment_4 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), ) ); - $comment_5 = $this->factory->comment->create( array( + $comment_5 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), ) ); - $comment_6 = $this->factory->comment->create( array( + $comment_6 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), diff --git a/tests/phpunit/tests/comment/dateQuery.php b/tests/phpunit/tests/comment/dateQuery.php index d64a8428c5..cccdb971dd 100644 --- a/tests/phpunit/tests/comment/dateQuery.php +++ b/tests/phpunit/tests/comment/dateQuery.php @@ -22,7 +22,7 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase { // Just some dummy posts to use as parents for comments for ( $i = 1; $i <= 2; $i++ ) { - $this->posts[$i] = $this->factory->post->create(); + $this->posts[$i] = self::$factory->post->create(); } // Be careful modifying this. Tests are coded to expect this exact sample data. @@ -39,7 +39,7 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase { ); foreach ( $comment_dates as $comment_date => $comment_parent ) { - $result = $this->factory->comment->create( array( + $result = self::$factory->comment->create( array( 'comment_date' => $comment_date, 'comment_post_ID' => $this->posts[ $comment_parent ], ) ); diff --git a/tests/phpunit/tests/comment/getCommentClass.php b/tests/phpunit/tests/comment/getCommentClass.php index 5ca3bc41ea..09bd5c8805 100644 --- a/tests/phpunit/tests/comment/getCommentClass.php +++ b/tests/phpunit/tests/comment/getCommentClass.php @@ -5,32 +5,32 @@ */ class Tests_Comment_GetCommentClass extends WP_UnitTestCase { public function test_should_accept_comment_id() { - $post_id = $this->factory->post->create(); - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) ); + $post_id = self::$factory->post->create(); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); $classes = get_comment_class( '', $comment_id ); $this->assertContains( 'comment', $classes ); } public function test_should_accept_comment_object() { - $post_id = $this->factory->post->create(); - $comment = $this->factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) ); + $post_id = self::$factory->post->create(); + $comment = self::$factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) ); $classes = get_comment_class( '', $comment ); $this->assertContains( 'comment', $classes ); } public function test_should_append_single_class() { - $post_id = $this->factory->post->create(); - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) ); + $post_id = self::$factory->post->create(); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); $classes = get_comment_class( 'foo', $comment_id ); $this->assertContains( 'foo', $classes ); } public function test_should_append_array_of_classes() { - $post_id = $this->factory->post->create(); - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) ); + $post_id = self::$factory->post->create(); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); $classes = get_comment_class( array( 'foo', 'bar' ), $comment_id ); $this->assertContains( 'foo', $classes ); diff --git a/tests/phpunit/tests/comment/getCommentCount.php b/tests/phpunit/tests/comment/getCommentCount.php index 4e22c1bb41..45ba8e798f 100644 --- a/tests/phpunit/tests/comment/getCommentCount.php +++ b/tests/phpunit/tests/comment/getCommentCount.php @@ -14,7 +14,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase { } public function test_get_comment_count_approved() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 1 ) ); @@ -29,7 +29,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase { } public function test_get_comment_count_awaiting() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 0 ) ); @@ -44,7 +44,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase { } public function test_get_comment_count_spam() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'spam' ) ); @@ -59,7 +59,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase { } public function test_get_comment_count_trash() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'trash' ) ); @@ -74,7 +74,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase { } public function test_get_comment_count_post_trashed() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'post-trashed' ) ); diff --git a/tests/phpunit/tests/comment/getCommentExcerpt.php b/tests/phpunit/tests/comment/getCommentExcerpt.php index 0ab97b74f8..6eee6e6689 100644 --- a/tests/phpunit/tests/comment/getCommentExcerpt.php +++ b/tests/phpunit/tests/comment/getCommentExcerpt.php @@ -14,7 +14,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco } public function test_get_comment_excerpt() { - $comment_id = $this->factory->comment->create( array( + $comment_id = self::$factory->comment->create( array( 'comment_content' => self::$bacon_comment ) ); @@ -24,7 +24,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco } public function test_get_comment_excerpt_filtered() { - $comment_id = $this->factory->comment->create( array( + $comment_id = self::$factory->comment->create( array( 'comment_content' => self::$bacon_comment ) ); diff --git a/tests/phpunit/tests/comment/getCommentLink.php b/tests/phpunit/tests/comment/getCommentLink.php index b42cf7ed93..0b4e44c832 100644 --- a/tests/phpunit/tests/comment/getCommentLink.php +++ b/tests/phpunit/tests/comment/getCommentLink.php @@ -11,33 +11,33 @@ class Tests_Comment_GetCommentLink extends WP_UnitTestCase { parent::setUp(); $now = time(); - $this->p = $this->factory->post->create(); - $this->comments[] = $this->factory->comment->create( array( + $this->p = self::$factory->post->create(); + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '1', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); - $this->comments[] = $this->factory->comment->create( array( + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '2', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), ) ); - $this->comments[] = $this->factory->comment->create( array( + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '3', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), ) ); - $this->comments[] = $this->factory->comment->create( array( + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), ) ); - $this->comments[] = $this->factory->comment->create( array( + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), ) ); - $this->comments[] = $this->factory->comment->create( array( + $this->comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $this->p, 'comment_content' => '4', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), diff --git a/tests/phpunit/tests/comment/getCommentsPagesCount.php b/tests/phpunit/tests/comment/getCommentsPagesCount.php index 6e742a877c..d6e21bc187 100644 --- a/tests/phpunit/tests/comment/getCommentsPagesCount.php +++ b/tests/phpunit/tests/comment/getCommentsPagesCount.php @@ -38,7 +38,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { */ function test_empty() { //setup post and comments - $post_id = $this->factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); $this->go_to( '/?p=' . $post_id ); global $wp_query; @@ -60,9 +60,9 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { */ function test_threaded_comments( ) { //setup post and comments - $post = $this->factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); - $comments = $this->factory->comment->create_post_comments( $post->ID, 15 ); - $this->factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); + $comments = self::$factory->comment->create_post_comments( $post->ID, 15 ); + self::$factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) ); $comments = get_comments( array( 'post_id' => $post->ID ) ); $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) ); @@ -76,9 +76,9 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { function test_option_thread_comments() { //setup post and comments - $post = $this->factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); - $comments = $this->factory->comment->create_post_comments( $post->ID, 15 ); - $this->factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); + $comments = self::$factory->comment->create_post_comments( $post->ID, 15 ); + self::$factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) ); $comments = get_comments( array( 'post_id' => $post->ID ) ); update_option( 'thread_comments', false ); @@ -104,8 +104,8 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { update_option( 'posts_per_rss', 100 ); - $post = $this->factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) ); - $comments = $this->factory->comment->create_post_comments( $post->ID, 25 ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) ); + $comments = self::$factory->comment->create_post_comments( $post->ID, 25 ); $wp_query = new WP_Query( array( 'p' => $post->ID, 'comments_per_page' => 10, 'feed' =>'comments-' ) ); diff --git a/tests/phpunit/tests/comment/getPageOfComment.php b/tests/phpunit/tests/comment/getPageOfComment.php index a088894652..390b6eda87 100644 --- a/tests/phpunit/tests/comment/getPageOfComment.php +++ b/tests/phpunit/tests/comment/getPageOfComment.php @@ -7,26 +7,26 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { public function test_last_comment() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); // page 4 - $comment_last = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) ); + $comment_last = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) ); // page 3 - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) ); // page 2 - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) ); // page 1 - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) ); - $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) ); - $comment_first = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) ); + self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) ); + $comment_first = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) ); $this->assertEquals( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) ); $this->assertEquals( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 10 ) ) ); @@ -36,18 +36,18 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { } public function test_type_pings() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $now = time(); $trackbacks = array(); for ( $i = 0; $i <= 3; $i++ ) { - $trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); + $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); $now -= 10 * $i; } $pingbacks = array(); for ( $i = 0; $i <= 6; $i++ ) { - $pingbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); + $pingbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); $now -= 10 * $i; } @@ -62,8 +62,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { public function test_subsequent_calls_should_hit_cache() { global $wpdb; - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); // Prime cache. $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); @@ -81,13 +81,13 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { public function test_cache_hits_should_be_sensitive_to_comment_type() { global $wpdb; - $p = $this->factory->post->create(); - $comment = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) ); + $p = self::$factory->post->create(); + $comment = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) ); $now = time(); $trackbacks = array(); for ( $i = 0; $i <= 5; $i++ ) { - $trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) ); + $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) ); } // Prime cache for trackbacks. @@ -105,8 +105,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 11334 */ public function test_cache_should_be_invalidated_when_comment_is_approved() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) ); // Prime cache. $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); @@ -121,8 +121,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 11334 */ public function test_cache_should_be_invalidated_when_comment_is_deleted() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); // Prime cache. $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); @@ -137,8 +137,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 11334 */ public function test_cache_should_be_invalidated_when_comment_is_spammed() { - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); // Prime cache. $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); @@ -155,10 +155,10 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { public function test_cache_should_be_invalidated_when_older_comment_is_published() { $now = time(); - $p = $this->factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); + $p = self::$factory->post->create(); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); $this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) ); @@ -171,13 +171,13 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 34057 */ public function test_query_should_be_limited_to_comments_on_the_proper_post() { - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); $now = time(); $comments_0 = $comments_1 = array(); for ( $i = 0; $i < 5; $i++ ) { - $comments_0[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); - $comments_1[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); + $comments_0[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); + $comments_1[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); } $found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) ); @@ -191,15 +191,15 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 13939 */ public function test_only_top_level_comments_should_be_included_in_older_count() { - $post = $this->factory->post->create(); + $post = self::$factory->post->create(); $now = time(); $comment_parents = $comment_children = array(); for ( $i = 0; $i < 5; $i++ ) { - $parent = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); + $parent = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); $comment_parents[ $i ] = $parent; - $child = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) ); + $child = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) ); $comment_children[ $i ] = $child; } @@ -228,10 +228,10 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { public function test_comments_per_page_option_should_be_fallback_when_query_var_is_not_available() { $now = time(); - $p = $this->factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); + $p = self::$factory->post->create(); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); update_option( 'comments_per_page', 2 ); diff --git a/tests/phpunit/tests/comment/metaCache.php b/tests/phpunit/tests/comment/metaCache.php index 7da45b1c81..67563255f2 100644 --- a/tests/phpunit/tests/comment/metaCache.php +++ b/tests/phpunit/tests/comment/metaCache.php @@ -10,8 +10,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_update_comment_meta_cache_should_default_to_true() { global $wpdb; - $p = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $comment_ids = $this->factory->comment->create_post_comments( $p, 3 ); + $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); foreach ( $comment_ids as $cid ) { update_comment_meta( $cid, 'foo', 'bar' ); @@ -38,8 +38,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_update_comment_meta_cache_true() { global $wpdb; - $p = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $comment_ids = $this->factory->comment->create_post_comments( $p, 3 ); + $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); foreach ( $comment_ids as $cid ) { update_comment_meta( $cid, 'foo', 'bar' ); @@ -67,8 +67,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_update_comment_meta_cache_false() { global $wpdb; - $p = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $comment_ids = $this->factory->comment->create_post_comments( $p, 3 ); + $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); foreach ( $comment_ids as $cid ) { update_comment_meta( $cid, 'foo', 'bar' ); @@ -93,8 +93,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() { global $wpdb; - $p = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $comment_ids = $this->factory->comment->create_post_comments( $p, 3 ); + $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); foreach ( $comment_ids as $cid ) { update_comment_meta( $cid, 'sauce', 'fire' ); @@ -128,12 +128,12 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() { global $wpdb; - $posts = $this->factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); + $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); $now = time(); $comments = array(); for ( $i = 0; $i < 5; $i++ ) { - $comments[] = $this->factory->comment->create( array( + $comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ), ) ); @@ -172,12 +172,12 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() { global $wpdb; - $posts = $this->factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); + $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); $now = time(); $comments = array(); for ( $i = 0; $i < 5; $i++ ) { - $comments[] = $this->factory->comment->create( array( + $comments[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ), ) ); diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 783974e7b7..9a1c79b735 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -12,15 +12,15 @@ class Tests_Comment_Query extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create(); + $this->post_id = self::$factory->post->create(); } public function test_query() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -31,7 +31,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_post_id_0() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -46,11 +46,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_query_type_empty_string() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -65,11 +65,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_query_type_comment() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -81,10 +81,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_type_pingback() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -97,10 +97,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_type_trackback() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -116,11 +116,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * 'pings' is an alias for 'trackback' + 'pingback'. */ public function test_query_type_pings() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -136,12 +136,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comments_and_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -156,12 +156,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_not__in_array_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -176,12 +176,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type__in_array_and_not_type_array_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -197,12 +197,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_and_type__not_in_array_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -218,12 +218,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type__not_in_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -238,11 +238,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comments_and_pings() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -257,9 +257,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comment_pings() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -274,9 +274,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pingback() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -291,9 +291,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_custom_pingpack() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -308,9 +308,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pings() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -325,10 +325,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_status_approved_array_comment_pings() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -344,9 +344,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_trackback() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -361,9 +361,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_custom_trackback() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -378,10 +378,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pings_approved() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -397,9 +397,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_empty_string() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -414,8 +414,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21101 */ public function test_status_hold() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -430,8 +430,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21101 */ public function test_status_approve() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -443,9 +443,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_custom() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -457,9 +457,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_all() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -471,9 +471,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_default_to_all() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -487,9 +487,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_comma_any() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -504,9 +504,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_comma_separated() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -521,9 +521,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_array() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -537,24 +537,24 @@ class Tests_Comment_Query extends WP_UnitTestCase { function test_get_comments_for_post() { $limit = 5; - $post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id, $limit ); + $post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id, $limit ); $comments = get_comments( array( 'post_id' => $post_id ) ); $this->assertEquals( $limit, count( $comments ) ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id, $comment->comment_post_ID ); } - $post_id2 = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id2, $limit ); + $post_id2 = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id2, $limit ); $comments = get_comments( array( 'post_id' => $post_id2 ) ); $this->assertEquals( $limit, count( $comments ) ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id2, $comment->comment_post_ID ); } - $post_id3 = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) ); + $post_id3 = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) ); $comments = get_comments( array( 'post_id' => $post_id3 ) ); $this->assertEquals( $limit, count( $comments ) ); foreach ( $comments as $comment ) { @@ -570,7 +570,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { $comments = get_comments( array( 'post_id' => $post_id3, 'status' => 'approve' ) ); $this->assertEquals( 0, count( $comments ) ); - $this->factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) ); + self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) ); $comments = get_comments( array( 'post_id' => $post_id3 ) ); $this->assertEquals( $limit * 2, count( $comments ) ); foreach ( $comments as $comment ) { @@ -582,9 +582,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21003 */ function test_orderby_meta() { - $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); - $comment_id2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); - $comment_id3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $comment_id2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $comment_id3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); add_comment_meta( $comment_id, 'key', 'value1', true ); add_comment_meta( $comment_id, 'key1', 'value1', true ); @@ -632,7 +632,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 30478 */ public function test_orderby_clause_key() { - $comments = $this->factory->comment->create_many( 3 ); + $comments = self::$factory->comment->create_many( 3 ); add_comment_meta( $comments[0], 'foo', 'aaa' ); add_comment_meta( $comments[1], 'foo', 'zzz' ); add_comment_meta( $comments[2], 'foo', 'jjj' ); @@ -657,13 +657,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 30478 */ public function test_orderby_clause_key_as_secondary_sort() { - $c1 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_date' => '2015-01-28 03:00:00', ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_date' => '2015-01-28 05:00:00', ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_date' => '2015-01-28 03:00:00', ) ); @@ -693,7 +693,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 30478 */ public function test_orderby_more_than_one_clause_key() { - $comments = $this->factory->comment->create_many( 3 ); + $comments = self::$factory->comment->create_many( 3 ); add_comment_meta( $comments[0], 'foo', 'jjj' ); add_comment_meta( $comments[1], 'foo', 'zzz' ); @@ -728,7 +728,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @group 32081 */ public function test_meta_query_should_work_with_comment__in() { - $comments = $this->factory->comment->create_many( 3 ); + $comments = self::$factory->comment->create_many( 3 ); add_comment_meta( $comments[0], 'foo', 'jjj' ); add_comment_meta( $comments[1], 'foo', 'zzz' ); @@ -752,7 +752,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @group 32081 */ public function test_meta_query_should_work_with_comment__not_in() { - $comments = $this->factory->comment->create_many( 3 ); + $comments = self::$factory->comment->create_many( 3 ); add_comment_meta( $comments[0], 'foo', 'jjj' ); add_comment_meta( $comments[1], 'foo', 'zzz' ); @@ -776,10 +776,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 27064 */ function test_get_comments_by_user() { - $users = $this->factory->user->create_many( 2 ); - $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $this->factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $users = self::$factory->user->create_many( 2 ); + self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + self::$factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); $comments = get_comments( array( 'user_id' => $users[0], @@ -808,9 +808,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 28434 */ function test_fields_ids_query() { - $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); // Ensure we are dealing with integers, and not objects. $this->assertInternalType( 'integer', $comment_1 ); @@ -826,9 +826,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_comment__in() { - $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -842,9 +842,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_comment__not_in() { - $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -858,13 +858,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_post__in() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -878,13 +878,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_post__not_in() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -901,13 +901,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { $author_id1 = 105; $author_id2 = 106; - $p1 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); - $p2 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); - $p3 = $this->factory->post->create( array( 'post_author' => $author_id2 ) ); + $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); + $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); + $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) ); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -924,13 +924,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { $author_id1 = 111; $author_id2 = 112; - $p1 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); - $p2 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); - $p3 = $this->factory->post->create( array( 'post_author' => $author_id2 ) ); + $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); + $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); + $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) ); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -944,15 +944,15 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29885 */ function test_fields_author__in() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -966,15 +966,15 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29885 */ function test_fields_author__not_in() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -988,9 +988,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_status_all() { - $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); $comments_approved_1 = get_comments( array( 'status' => 'all' ) ); $comment_ids = get_comments( array( 'fields' => 'ids' ) ); @@ -1001,10 +1001,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1019,11 +1019,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id_array() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1038,11 +1038,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id_comma_separated() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1057,10 +1057,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_author_email() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1075,11 +1075,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_mixed_array() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1094,11 +1094,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_mixed_comma_separated() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1110,12 +1110,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_search() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); - $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); - $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); - $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1363,7 +1363,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() { $now = current_time( 'mysql', 1 ); - $comments = $this->factory->comment->create_many( 5, array( + $comments = self::$factory->comment->create_many( 5, array( 'comment_post_ID' => $this->post_id, 'comment_date_gmt' => $now, ) ); @@ -1383,7 +1383,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() { $now = current_time( 'mysql', 1 ); - $comments = $this->factory->comment->create_many( 5, array( + $comments = self::$factory->comment->create_many( 5, array( 'comment_post_ID' => $this->post_id, 'comment_date_gmt' => $now, ) ); @@ -1416,8 +1416,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_count() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1431,9 +1431,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 23369 */ public function test_count_with_meta_query() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); add_comment_meta( $c1, 'foo', 'bar' ); add_comment_meta( $c3, 'foo', 'bar' ); @@ -1455,11 +1455,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { register_post_type( 'post-type-1' ); register_post_type( 'post-type-2' ); - $p1 = $this->factory->post->create( array( 'post_type' => 'post-type-1' ) ); - $p2 = $this->factory->post->create( array( 'post_type' => 'post-type-2' ) ); + $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); + $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1480,11 +1480,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { register_post_type( 'post-type-1' ); register_post_type( 'post-type-2' ); - $p1 = $this->factory->post->create( array( 'post_type' => 'post-type-1' ) ); - $p2 = $this->factory->post->create( array( 'post_type' => 'post-type-2' ) ); + $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); + $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1505,13 +1505,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { register_post_type( 'post-type-1' ); register_post_type( 'post-type-2' ); - $p1 = $this->factory->post->create( array( 'post_type' => 'post-type-1' ) ); - $p2 = $this->factory->post->create( array( 'post_type' => 'post-type-2' ) ); - $p3 = $this->factory->post->create( array( 'post_type' => 'post-type-3' ) ); + $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); + $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); + $p3 = self::$factory->post->create( array( 'post_type' => 'post-type-3' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); - $c3 = $this->factory->comment->create_post_comments( $p3, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); + $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1526,11 +1526,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_post_name_single_value() { - $p1 = $this->factory->post->create( array( 'post_name' => 'foo' ) ); - $p2 = $this->factory->post->create( array( 'post_name' => 'bar' ) ); + $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); + $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1545,11 +1545,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 20006 */ public function test_post_name_singleton_array() { - $p1 = $this->factory->post->create( array( 'post_name' => 'foo' ) ); - $p2 = $this->factory->post->create( array( 'post_name' => 'bar' ) ); + $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); + $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1564,13 +1564,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 20006 */ public function test_post_name_array() { - $p1 = $this->factory->post->create( array( 'post_name' => 'foo' ) ); - $p2 = $this->factory->post->create( array( 'post_name' => 'bar' ) ); - $p3 = $this->factory->post->create( array( 'post_name' => 'baz' ) ); + $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); + $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); + $p3 = self::$factory->post->create( array( 'post_name' => 'baz' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); - $c3 = $this->factory->comment->create_post_comments( $p3, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); + $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1582,11 +1582,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_post_status_single_value() { - $p1 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $p2 = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1601,11 +1601,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 20006 */ public function test_post_status_singleton_array() { - $p1 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $p2 = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1620,13 +1620,13 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 20006 */ public function test_post_status_array() { - $p1 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); - $p2 = $this->factory->post->create( array( 'post_status' => 'draft' ) ); - $p3 = $this->factory->post->create( array( 'post_status' => 'future' ) ); + $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); + $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); + $p3 = self::$factory->post->create( array( 'post_status' => 'future' ) ); - $c1 = $this->factory->comment->create_post_comments( $p1, 1 ); - $c2 = $this->factory->comment->create_post_comments( $p2, 1 ); - $c3 = $this->factory->comment->create_post_comments( $p3, 1 ); + $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); + $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); + $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1641,7 +1641,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 24826 */ public function test_comment_query_object() { - $comment_id = $this->factory->comment->create(); + $comment_id = self::$factory->comment->create(); $query1 = new WP_Comment_Query(); $this->assertNull( $query1->query_vars ); @@ -1663,8 +1663,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_comment_cache_key_should_ignore_custom_params() { global $wpdb; - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); $q1 = new WP_Comment_Query(); $q1->query( array( @@ -1688,7 +1688,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 32762 */ public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() { - $comments = $this->factory->comment->create_many( 2, array( + $comments = self::$factory->comment->create_many( 2, array( 'comment_post_ID' => $this->post_id, ) ); @@ -1719,7 +1719,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 32762 */ public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() { - $comments = $this->factory->comment->create_many( 2, array( + $comments = self::$factory->comment->create_many( 2, array( 'comment_post_ID' => $this->post_id, ) ); @@ -1746,8 +1746,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__in() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, @@ -1766,17 +1766,17 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__in_commas() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c4 = $this->factory->comment->create( array( + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c2, @@ -1795,9 +1795,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__not_in() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, @@ -1816,18 +1816,18 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__not_in_commas() { - $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c2, @@ -1846,21 +1846,21 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33883 */ public function test_orderby_comment__in() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); @@ -1880,7 +1880,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_no_found_rows_should_default_to_true() { - $comments = $this->factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); $q = new WP_Comment_Query( array( 'post_id' => $this->post_id, @@ -1895,7 +1895,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_should_respect_no_found_rows_true() { - $comments = $this->factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); $q = new WP_Comment_Query( array( 'post_id' => $this->post_id, @@ -1911,7 +1911,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_should_respect_no_found_rows_false() { - $comments = $this->factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); $q = new WP_Comment_Query( array( 'post_id' => $this->post_id, @@ -1927,18 +1927,18 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_hierarchical_should_skip_child_comments_in_offset() { - $top_level_0 = $this->factory->comment->create( array( + $top_level_0 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $child_of_0 = $this->factory->comment->create( array( + $child_of_0 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); - $top_level_comments = $this->factory->comment->create_many( 3, array( + $top_level_comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); @@ -1960,18 +1960,18 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_hierarchical_should_not_include_child_comments_in_number() { - $top_level_0 = $this->factory->comment->create( array( + $top_level_0 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $child_of_0 = $this->factory->comment->create( array( + $child_of_0 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); - $top_level_comments = $this->factory->comment->create_many( 3, array( + $top_level_comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); @@ -1991,35 +1991,35 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_hierarchical_threaded() { - $c1 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c2, ) ); - $c4 = $this->factory->comment->create( array( + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c5 = $this->factory->comment->create( array( + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $c6 = $this->factory->comment->create( array( + $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c5, @@ -2054,35 +2054,35 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_hierarchical_threaded_approved() { - $c1 = $this->factory->comment->create( array( + $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $c2 = $this->factory->comment->create( array( + $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c3 = $this->factory->comment->create( array( + $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_parent' => $c2, ) ); - $c4 = $this->factory->comment->create( array( + $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); - $c5 = $this->factory->comment->create( array( + $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_parent' => $c5, @@ -2117,8 +2117,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_update_comment_post_cache_should_be_disabled_by_default() { global $wpdb; - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); $q = new WP_Comment_Query( array( 'post_ID' => $p, @@ -2135,8 +2135,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_should_respect_update_comment_post_cache_true() { global $wpdb; - $p = $this->factory->post->create(); - $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) ); + $p = self::$factory->post->create(); + $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); $q = new WP_Comment_Query( array( 'post_ID' => $p, diff --git a/tests/phpunit/tests/comment/slashes.php b/tests/phpunit/tests/comment/slashes.php index 6b3cecdcd6..01b4e99e49 100644 --- a/tests/phpunit/tests/comment/slashes.php +++ b/tests/phpunit/tests/comment/slashes.php @@ -9,7 +9,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { function setUp() { parent::setUp(); // we need an admin user to bypass comment flood protection - $this->author_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); @@ -34,7 +34,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { * */ function test_wp_new_comment() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); // not testing comment_author_email or comment_author_url // as slashes are not permitted in that data @@ -74,8 +74,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { * */ function test_edit_comment() { - $post_id = $this->factory->post->create(); - $comment_id = $this->factory->comment->create(array( + $post_id = self::$factory->post->create(); + $comment_id = self::$factory->comment->create(array( 'comment_post_ID' => $post_id )); @@ -117,7 +117,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { * */ function test_wp_insert_comment() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $comment_id = wp_insert_comment(array( 'comment_post_ID' => $post_id, @@ -145,8 +145,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { * */ function test_wp_update_comment() { - $post_id = $this->factory->post->create(); - $comment_id = $this->factory->comment->create(array( + $post_id = self::$factory->post->create(); + $comment_id = self::$factory->comment->create(array( 'comment_post_ID' => $post_id )); diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 1ffdc0cbfe..8556cb0db1 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -5,26 +5,26 @@ class Tests_Comment_Template extends WP_UnitTestCase { function test_get_comments_number() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->assertEquals( 0, get_comments_number( 0 ) ); $this->assertEquals( 0, get_comments_number( $post_id ) ); $this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) ); - $this->factory->comment->create_post_comments( $post_id, 12 ); + self::$factory->comment->create_post_comments( $post_id, 12 ); $this->assertEquals( 12, get_comments_number( $post_id ) ); $this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) ); } function test_get_comments_number_without_arg() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $this->go_to( $permalink ); $this->assertEquals( 0, get_comments_number() ); - $this->factory->comment->create_post_comments( $post_id, 12 ); + self::$factory->comment->create_post_comments( $post_id, 12 ); $this->go_to( $permalink ); $this->assertEquals( 12, get_comments_number() ); diff --git a/tests/phpunit/tests/comment/walker.php b/tests/phpunit/tests/comment/walker.php index ee17af4fd0..8dd2607150 100644 --- a/tests/phpunit/tests/comment/walker.php +++ b/tests/phpunit/tests/comment/walker.php @@ -8,15 +8,15 @@ class Tests_Comment_Walker extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create(); + $this->post_id = self::$factory->post->create(); } /** * @ticket 14041 */ function test_has_children() { - $comment_parent = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); - $comment_child = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) ); + $comment_parent = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $comment_child = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) ); $comment_parent = get_comment( $comment_parent ); $comment_child = get_comment( $comment_child ); diff --git a/tests/phpunit/tests/comment/wpCountComments.php b/tests/phpunit/tests/comment/wpCountComments.php index d35bb26f2d..b618fbeef1 100644 --- a/tests/phpunit/tests/comment/wpCountComments.php +++ b/tests/phpunit/tests/comment/wpCountComments.php @@ -15,7 +15,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_approved() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 1 ) ); @@ -31,7 +31,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_awaiting() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 0 ) ); @@ -47,7 +47,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_spam() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'spam' ) ); @@ -63,7 +63,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_trash() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'trash' ) ); @@ -79,7 +79,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_post_trashed() { - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_approved' => 'post-trashed' ) ); @@ -95,10 +95,10 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase { } public function test_wp_count_comments_cache() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_status' => 'publish' ) ); - $comment_id = $this->factory->comment->create( array( + $comment_id = self::$factory->comment->create( array( 'comment_approved' => '1', 'comment_post_ID' => $post_id ) ); diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index a484a8a205..ec9e2b05c4 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -251,10 +251,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Manager::set_return_url() */ function test_return_url() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'author' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'author' ) ) ); $this->assertEquals( get_admin_url(), $this->manager->get_return_url() ); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $this->assertTrue( current_user_can( 'edit_theme_options' ) ); $this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() ); @@ -301,7 +301,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Manager::customize_pane_settings() */ function test_customize_pane_settings() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $this->manager->register_controls(); $this->manager->prepare_controls(); $autofocus = array( 'control' => 'blogname' ); diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index 2e96570c3e..fab713e837 100644 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -21,7 +21,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { function setUp() { parent::setUp(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; $this->wp_customize = new WP_Customize_Manager(); @@ -149,7 +149,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { function test_value_type_post_type() { do_action( 'customize_register', $this->wp_customize ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $menu_id = wp_create_nav_menu( 'Menu' ); $item_title = 'Greetings'; @@ -192,7 +192,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { function test_value_type_taxonomy() { do_action( 'customize_register', $this->wp_customize ); - $tax_id = $this->factory->category->create( array( 'name' => 'Salutations' ) ); + $tax_id = self::$factory->category->create( array( 'name' => 'Salutations' ) ); $menu_id = wp_create_nav_menu( 'Menu' ); $item_title = 'Greetings'; @@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { $value = $menu->value(); $this->assertEquals( $post_value, $value ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_id = wp_update_nav_menu_item( $menu_id, 0, array( 'menu-item-type' => 'post_type', 'menu-item-object' => 'post', @@ -296,8 +296,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { function test_preview_updated() { do_action( 'customize_register', $this->wp_customize ); - $first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); - $second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) ); + $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); + $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) ); $primary_menu_id = wp_create_nav_menu( 'Primary' ); $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); @@ -348,7 +348,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_ids = array(); for ( $i = 0; $i < 5; $i += 1 ) { $item_id = wp_update_nav_menu_item( $menu_id, 0, array( @@ -403,7 +403,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_ids = array(); for ( $i = 0; $i < 5; $i += 1 ) { $item_id = wp_update_nav_menu_item( $menu_id, 0, array( @@ -488,8 +488,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { function test_save_updated() { do_action( 'customize_register', $this->wp_customize ); - $first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); - $second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) ); + $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); + $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) ); $primary_menu_id = wp_create_nav_menu( 'Primary' ); $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); @@ -554,7 +554,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_ids = array(); for ( $i = 0; $i < 5; $i += 1 ) { $item_id = wp_update_nav_menu_item( $menu_id, 0, array( @@ -623,7 +623,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_ids = array(); for ( $i = 0; $i < 5; $i += 1 ) { $item_id = wp_update_nav_menu_item( $menu_id, 0, array( diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index fd66d4ca93..7f4616c456 100644 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -22,7 +22,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { function setUp() { parent::setUp(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; $this->wp_customize = new WP_Customize_Manager(); diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 7e85c76d15..5add12999b 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -22,7 +22,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { function setUp() { parent::setUp(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; $this->wp_customize = new WP_Customize_Manager(); $wp_customize = $this->wp_customize; @@ -124,7 +124,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { ); // Create pages. - $this->factory->post->create_many( 12, array( 'post_type' => 'page' ) ); + self::$factory->post->create_many( 12, array( 'post_type' => 'page' ) ); // Home is included in menu items when page is zero. $items = $menus->load_available_items_query( 'post_type', 'page', 0 ); @@ -145,10 +145,10 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create page. - $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) ); // Create pages. - $this->factory->post->create_many( 10 ); + self::$factory->post->create_many( 10 ); // Expected menu item array. $expected = array( @@ -175,7 +175,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create page. - $page_id = $this->factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); + $page_id = self::$factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); // Expected menu item array. $expected = array( @@ -201,7 +201,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create post. - $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) ); // Expected menu item array. $expected = array( @@ -227,7 +227,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create term. - $term_id = $this->factory->category->create( array( 'name' => 'Term Title' ) ); + $term_id = self::$factory->category->create( array( 'name' => 'Term Title' ) ); // Expected menu item array. $expected = array( @@ -279,13 +279,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { // Create posts $post_ids = array(); - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'Search & Test' ) ); - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'Some Other Title' ) ); + $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) ); + $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Some Other Title' ) ); // Create terms $term_ids = array(); - $term_ids[] = $this->factory->category->create( array( 'name' => 'Dogs Are Cool' ) ); - $term_ids[] = $this->factory->category->create( array( 'name' => 'Cats Drool' ) ); + $term_ids[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) ); + $term_ids[] = self::$factory->category->create( array( 'name' => 'Cats Drool' ) ); // Test empty results $expected = array(); @@ -386,7 +386,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { function test_customize_register() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); $item_id = wp_update_nav_menu_item( $menu_id, 0, array( 'menu-item-type' => 'post_type', 'menu-item-object' => 'post', diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php index d1c3bb1768..f1b62cb9e6 100644 --- a/tests/phpunit/tests/customize/panel.php +++ b/tests/phpunit/tests/customize/panel.php @@ -128,7 +128,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::check_capabilities() */ function test_check_capabilities() { - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); $panel = new WP_Customize_Panel( $this->manager, 'foo' ); @@ -154,7 +154,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::maybe_render() */ function test_maybe_render() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $panel = new WP_Customize_Panel( $this->manager, 'bar' ); $customize_render_panel_count = did_action( 'customize_render_panel' ); add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) ); @@ -179,7 +179,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::print_template() */ function test_print_templates_standard() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $panel = new WP_Customize_Panel( $this->manager, 'baz' ); ob_start(); @@ -197,7 +197,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::print_template() */ function test_print_templates_custom() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $panel = new Custom_Panel_Test( $this->manager, 'baz' ); ob_start(); diff --git a/tests/phpunit/tests/customize/section.php b/tests/phpunit/tests/customize/section.php index 82343e7315..2ed81b675e 100644 --- a/tests/phpunit/tests/customize/section.php +++ b/tests/phpunit/tests/customize/section.php @@ -135,7 +135,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::check_capabilities() */ function test_check_capabilities() { - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); $section = new WP_Customize_Section( $this->manager, 'foo' ); @@ -161,7 +161,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::maybe_render() */ function test_maybe_render() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $section = new WP_Customize_Section( $this->manager, 'bar' ); $customize_render_section_count = did_action( 'customize_render_section' ); add_action( 'customize_render_section', array( $this, 'action_customize_render_section_test' ) ); @@ -186,7 +186,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::print_template() */ function test_print_templates_standard() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $section = new WP_Customize_Section( $this->manager, 'baz' ); ob_start(); @@ -201,7 +201,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::print_template() */ function test_print_templates_custom() { - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $section = new Custom_Section_Test( $this->manager, 'baz' ); ob_start(); diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php index 600fb3faa9..803f09088b 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -394,7 +394,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { $this->assertTrue( 0 === did_action( 'customize_save_foo' ) ); // Satisfy all requirements for save to happen. - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $this->assertTrue( false !== $setting->save() ); $this->assertTrue( 1 === did_action( 'customize_update_custom' ) ); $this->assertTrue( 1 === did_action( 'customize_save_foo' ) ); @@ -465,7 +465,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { $setting->preview(); $this->assertTrue( $setting->is_current_blog_previewed() ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); $this->assertFalse( $setting->is_current_blog_previewed() ); $this->assertNotEquals( $post_value, $setting->value() ); diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index 50aab183e8..e8a83a01ed 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -30,7 +30,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); } diff --git a/tests/phpunit/tests/date/query.php b/tests/phpunit/tests/date/query.php index 99c6ca5389..7ce816572e 100644 --- a/tests/phpunit/tests/date/query.php +++ b/tests/phpunit/tests/date/query.php @@ -975,8 +975,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { * @ticket 31001 */ public function test_validate_date_values_should_process_array_value_for_year() { - $p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) ); $q = new WP_Query( array( 'date_query' => array( @@ -995,8 +995,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { * @ticket 31001 */ public function test_validate_date_values_should_process_array_value_for_day() { - $p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); $q = new WP_Query( array( 'date_query' => array( @@ -1016,8 +1016,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { * @expectedIncorrectUsage WP_Date_Query */ public function test_validate_date_values_should_process_array_value_for_day_when_values_are_invalid() { - $p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); $q = new WP_Query( array( 'date_query' => array( diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 23274359fd..fd3517db1c 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -509,7 +509,7 @@ class Tests_DB extends WP_UnitTestCase { $this->markTestSkipped( 'procedure could not be created (missing privileges?)' ); } - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->assertNotEmpty( $wpdb->get_results( 'CALL `test_mysqli_flush_sync_procedure`' ) ); $this->assertNotEmpty( $wpdb->get_results( "SELECT ID FROM `{$wpdb->posts}` LIMIT 1" ) ); diff --git a/tests/phpunit/tests/formatting/SanitizePost.php b/tests/phpunit/tests/formatting/SanitizePost.php index 5dad0beb25..691c0822bc 100644 --- a/tests/phpunit/tests/formatting/SanitizePost.php +++ b/tests/phpunit/tests/formatting/SanitizePost.php @@ -9,7 +9,7 @@ class Tests_Formatting_SanitizePost extends WP_UnitTestCase { * @ticket 22324 */ function test_int_fields() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $int_fields = array( 'ID' => 'integer', 'post_parent' => 'integer', diff --git a/tests/phpunit/tests/formatting/WpTrimExcerpt.php b/tests/phpunit/tests/formatting/WpTrimExcerpt.php index d95224765c..8aafa8e0f1 100644 --- a/tests/phpunit/tests/formatting/WpTrimExcerpt.php +++ b/tests/phpunit/tests/formatting/WpTrimExcerpt.php @@ -9,10 +9,10 @@ class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { * @ticket 25349 */ public function test_secondary_loop_respect_more() { - $post1 = $this->factory->post->create( array( + $post1 = self::$factory->post->create( array( 'post_content' => 'Post 1 Page 1Post 1 Page 2', ) ); - $post2 = $this->factory->post->create( array( + $post2 = self::$factory->post->create( array( 'post_content' => 'Post 2 Page 1Post 2 Page 2', ) ); @@ -34,10 +34,10 @@ class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { * @ticket 25349 */ public function test_secondary_loop_respect_nextpage() { - $post1 = $this->factory->post->create( array( + $post1 = self::$factory->post->create( array( 'post_content' => 'Post 1 Page 1Post 1 Page 2', ) ); - $post2 = $this->factory->post->create( array( + $post2 = self::$factory->post->create( array( 'post_content' => 'Post 2 Page 1Post 2 Page 2', ) ); diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 1f45cd91e0..d44f47060c 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -689,7 +689,7 @@ class Tests_Functions extends WP_UnitTestCase { $actual = ob_get_clean(); $this->assertEquals( '', $actual ); - $GLOBALS['post'] = $this->factory->post->create_and_get( array( + $GLOBALS['post'] = self::$factory->post->create_and_get( array( 'post_date' => '2015-09-16 08:00:00' ) ); diff --git a/tests/phpunit/tests/functions/getArchives.php b/tests/phpunit/tests/functions/getArchives.php index ff2879da2c..393808d73a 100644 --- a/tests/phpunit/tests/functions/getArchives.php +++ b/tests/phpunit/tests/functions/getArchives.php @@ -87,7 +87,7 @@ EOF; } function test_wp_get_archives_order() { - $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) ); + self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) ); $date_full = date( 'F Y' ); $oct_url = get_month_link( 2012, 10 ); @@ -110,7 +110,7 @@ EOF; function test_wp_get_archives_post_type() { register_post_type( 'taco', array( 'public' => true ) ); - $this->factory->post->create( array( + self::$factory->post->create( array( 'post_type' => 'taco', 'post_author' => '1', 'post_date' => '2014-10-23 19:34:42' diff --git a/tests/phpunit/tests/general/archives.php b/tests/phpunit/tests/general/archives.php index 0c5642ac6a..e34e6c1a36 100644 --- a/tests/phpunit/tests/general/archives.php +++ b/tests/phpunit/tests/general/archives.php @@ -16,7 +16,7 @@ class Tests_General_Archives extends WP_UnitTestCase { function test_get_archives_cache() { global $wpdb; - $this->factory->post->create_many( 3, array( 'post_type' => 'post' ) ); + self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) ); wp_cache_delete( 'last_changed', 'posts' ); $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index 9136eeca8c..e7c6929646 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -34,7 +34,7 @@ class TestFactoryFor extends WP_UnitTestCase { */ public function test_term_factory_create_and_get_should_return_term_object() { register_taxonomy( 'wptests_tax', 'post' ); - $term = $this->factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertInternalType( 'object', $term ); $this->assertNotEmpty( $term->term_id ); } diff --git a/tests/phpunit/tests/link.php b/tests/phpunit/tests/link.php index 777347b702..08275d11bd 100644 --- a/tests/phpunit/tests/link.php +++ b/tests/phpunit/tests/link.php @@ -33,8 +33,8 @@ class Tests_Link extends WP_UnitTestCase { } function test_wp_get_shortlink() { - $post_id = $this->factory->post->create(); - $post_id2 = $this->factory->post->create(); + $post_id = self::$factory->post->create(); + $post_id2 = self::$factory->post->create(); // Basic case $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) ); @@ -77,7 +77,7 @@ class Tests_Link extends WP_UnitTestCase { } function test_wp_get_shortlink_with_page() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); // Basic case // Don't test against get_permalink() since it uses ?page_id= for pages. @@ -92,7 +92,7 @@ class Tests_Link extends WP_UnitTestCase { * @ticket 26871 */ function test_wp_get_shortlink_with_home_page() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $post_id ); @@ -108,22 +108,22 @@ class Tests_Link extends WP_UnitTestCase { */ function test_get_adjacent_post() { // Need some sample posts to test adjacency - $post_one = $this->factory->post->create_and_get( array( + $post_one = self::$factory->post->create_and_get( array( 'post_title' => 'First', 'post_date' => '2012-01-01 12:00:00' ) ); - $post_two = $this->factory->post->create_and_get( array( + $post_two = self::$factory->post->create_and_get( array( 'post_title' => 'Second', 'post_date' => '2012-02-01 12:00:00' ) ); - $post_three = $this->factory->post->create_and_get( array( + $post_three = self::$factory->post->create_and_get( array( 'post_title' => 'Third', 'post_date' => '2012-03-01 12:00:00' ) ); - $post_four = $this->factory->post->create_and_get( array( + $post_four = self::$factory->post->create_and_get( array( 'post_title' => 'Fourth', 'post_date' => '2012-04-01 12:00:00' ) ); @@ -183,33 +183,33 @@ class Tests_Link extends WP_UnitTestCase { global $wpdb; $wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) ); - $include = $this->factory->term->create( array( + $include = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Include', ) ); - $exclude = $this->factory->category->create(); + $exclude = self::$factory->category->create(); - $one = $this->factory->post->create_and_get( array( + $one = self::$factory->post->create_and_get( array( 'post_date' => '2012-01-01 12:00:00', 'post_category' => array( $include, $exclude ), ) ); - $two = $this->factory->post->create_and_get( array( + $two = self::$factory->post->create_and_get( array( 'post_date' => '2012-01-02 12:00:00', 'post_category' => array(), ) ); - $three = $this->factory->post->create_and_get( array( + $three = self::$factory->post->create_and_get( array( 'post_date' => '2012-01-03 12:00:00', 'post_category' => array( $include, $exclude ), ) ); - $four = $this->factory->post->create_and_get( array( + $four = self::$factory->post->create_and_get( array( 'post_date' => '2012-01-04 12:00:00', 'post_category' => array( $include ), ) ); - $five = $this->factory->post->create_and_get( array( + $five = self::$factory->post->create_and_get( array( 'post_date' => '2012-01-05 12:00:00', 'post_category' => array( $include, $exclude ), ) ); @@ -249,13 +249,13 @@ class Tests_Link extends WP_UnitTestCase { public function test_get_adjacent_post_excluded_terms() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); @@ -281,13 +281,13 @@ class Tests_Link extends WP_UnitTestCase { public function test_get_adjacent_post_excluded_terms_should_not_require_posts_to_have_terms_in_any_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); @@ -348,7 +348,7 @@ class Tests_Link extends WP_UnitTestCase { flush_rewrite_rules(); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_status' => 'publish', 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) ) ); @@ -368,7 +368,7 @@ class Tests_Link extends WP_UnitTestCase { flush_rewrite_rules(); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_type' => 'wptests_pt', 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) @@ -388,7 +388,7 @@ class Tests_Link extends WP_UnitTestCase { public function test_unattached_attachment_has_a_pretty_permalink() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', 'post_title' => 'An Attachment!', @@ -412,9 +412,9 @@ class Tests_Link extends WP_UnitTestCase { flush_rewrite_rules(); - $post_id = $this->factory->post->create( array( 'post_type' => 'not_a_post_type' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'not_a_post_type' ) ); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', 'post_title' => 'An Attachment!', diff --git a/tests/phpunit/tests/link/getAdjacentPostLink.php b/tests/phpunit/tests/link/getAdjacentPostLink.php index 9b80a056e7..08064e1db1 100644 --- a/tests/phpunit/tests/link/getAdjacentPostLink.php +++ b/tests/phpunit/tests/link/getAdjacentPostLink.php @@ -10,13 +10,13 @@ class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase { public function setUp(){ parent::setUp(); - $this->cat_id = $this->factory->category->create( array( 'name' => 'other' ) ); + $this->cat_id = self::$factory->category->create( array( 'name' => 'other' ) ); $this->post_ids = array(); - $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) ); - $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) ); - $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) ); - $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) ); - $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) ); + $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) ); + $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) ); + $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) ); + $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) ); + $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) ); //set current post (has 2 on each end) global $GLOBALS; @@ -25,37 +25,43 @@ class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase { public function test_get_next_post_link_default() { $actual = get_next_post_link(); - $expected = ' »'; + $title = get_post( $this->post_ids[1] )->post_title; + $expected = ' »'; $this->assertSame( $expected, $actual ); } public function test_get_previous_post_link_default() { $actual = get_previous_post_link(); - $expected = '« '; + $title = get_post( $this->post_ids[3] )->post_title; + $expected = '« '; $this->assertSame( $expected, $actual ); } public function test_get_next_post_link_same_category() { $actual = get_next_post_link( '%link »', '%title', true ); - $expected = ' »'; + $title = get_post( $this->post_ids[1] )->post_title; + $expected = ' »'; $this->assertSame( $expected, $actual ); } public function test_get_previous_post_link_same_category() { $actual = get_previous_post_link( '« %link', '%title', true ); - $expected = '« '; + $title = get_post( $this->post_ids[3] )->post_title; + $expected = '« '; $this->assertSame( $expected, $actual ); } public function test_get_next_post_link_exclude_category() { $actual = get_next_post_link( '%link »', '%title', false, $this->cat_id ); - $expected = ' »'; + $title = get_post( $this->post_ids[1] )->post_title; + $expected = ' »'; $this->assertSame( $expected, $actual ); } public function test_get_previous_post_link_exclude_category() { $actual = get_previous_post_link( '« %link', '%title', false, $this->cat_id ); - $expected = '« '; + $title = get_post( $this->post_ids[3] )->post_title; + $expected = '« '; $this->assertSame( $expected, $actual ); } } diff --git a/tests/phpunit/tests/link/getNextCommentsLink.php b/tests/phpunit/tests/link/getNextCommentsLink.php index 4459fa6359..8f148dba55 100644 --- a/tests/phpunit/tests/link/getNextCommentsLink.php +++ b/tests/phpunit/tests/link/getNextCommentsLink.php @@ -8,7 +8,7 @@ class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase { public function test_page_should_respect_value_of_cpage_query_var() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $this->go_to( get_permalink( $p ) ); $cpage = get_query_var( 'cpage' ); @@ -25,7 +25,7 @@ class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase { * @ticket 20319 */ public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $this->go_to( get_permalink( $p ) ); $cpage = get_query_var( 'cpage' ); diff --git a/tests/phpunit/tests/link/getPostCommentsFeedLink.php b/tests/phpunit/tests/link/getPostCommentsFeedLink.php index b2474d8e00..e3972fccc5 100644 --- a/tests/phpunit/tests/link/getPostCommentsFeedLink.php +++ b/tests/phpunit/tests/link/getPostCommentsFeedLink.php @@ -5,7 +5,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { public function test_post_link() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $link = get_post_comments_feed_link( $post_id ); $expected = add_query_arg( array( @@ -19,7 +19,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { public function test_post_pretty_link() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $link = get_post_comments_feed_link( $post_id ); $expected = get_permalink( $post_id ) . 'feed/'; @@ -28,8 +28,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_attachment_link() { - $post_id = $this->factory->post->create(); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( + $post_id = self::$factory->post->create(); + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -46,10 +46,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { public function test_attachment_pretty_link() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_status' => 'publish' ) ); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', 'post_title' => 'Burrito' @@ -66,8 +66,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { public function test_attachment_no_name_pretty_link() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $post_id = $this->factory->post->create(); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( + $post_id = self::$factory->post->create(); + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -79,7 +79,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_unattached_link() { - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -96,7 +96,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { public function test_unattached_pretty_link() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( + $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); diff --git a/tests/phpunit/tests/link/getPreviousCommentsLink.php b/tests/phpunit/tests/link/getPreviousCommentsLink.php index 4aa336dd9c..ea9ad6ccd5 100644 --- a/tests/phpunit/tests/link/getPreviousCommentsLink.php +++ b/tests/phpunit/tests/link/getPreviousCommentsLink.php @@ -8,7 +8,7 @@ class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { public function test_page_should_respect_value_of_cpage_query_var() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $this->go_to( get_permalink( $p ) ); $cpage = get_query_var( 'cpage' ); @@ -22,7 +22,7 @@ class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { } public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $this->go_to( get_permalink( $p ) ); $cpage = get_query_var( 'cpage' ); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index b1e95b1efc..b68a5377fa 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -236,8 +236,8 @@ EOF; * @ticket 22960 */ function test_get_attached_images() { - $post_id = $this->factory->post->create(); - $attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array( + $post_id = self::$factory->post->create(); + $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -253,7 +253,7 @@ EOF; $ids1 = array(); $ids1_srcs = array(); foreach ( range( 1, 3 ) as $i ) { - $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( + $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -266,7 +266,7 @@ EOF; $ids2 = array(); $ids2_srcs = array(); foreach ( range( 4, 6 ) as $i ) { - $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( + $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -284,7 +284,7 @@ EOF; [gallery ids="$ids2_joined"] BLOB; - $post_id = $this->factory->post->create( array( 'post_content' => $blob ) ); + $post_id = self::$factory->post->create( array( 'post_content' => $blob ) ); $srcs = get_post_galleries_images( $post_id ); $this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) ); } @@ -296,7 +296,7 @@ BLOB; $ids1 = array(); $ids1_srcs = array(); foreach ( range( 1, 3 ) as $i ) { - $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( + $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -309,7 +309,7 @@ BLOB; $ids2 = array(); $ids2_srcs = array(); foreach ( range( 4, 6 ) as $i ) { - $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( + $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -327,7 +327,7 @@ BLOB; [gallery ids="$ids2_joined"] BLOB; - $post_id = $this->factory->post->create( array( 'post_content' => $blob ) ); + $post_id = self::$factory->post->create( array( 'post_content' => $blob ) ); $srcs = get_post_gallery_images( $post_id ); $this->assertEquals( $srcs, $ids1_srcs ); } @@ -505,7 +505,7 @@ VIDEO; */ function test_attachment_url_to_postid() { $image_path = '2014/11/' . $this->img_name; - $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( + $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); @@ -516,7 +516,7 @@ VIDEO; function test_attachment_url_to_postid_schemes() { $image_path = '2014/11/' . $this->img_name; - $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( + $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); @@ -530,7 +530,7 @@ VIDEO; function test_attachment_url_to_postid_filtered() { $image_path = '2014/11/' . $this->img_name; - $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( + $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); @@ -704,8 +704,8 @@ EOF; function test_wp_get_attachment_image_url() { $this->assertFalse( wp_get_attachment_image_url( 0 ) ); - $post_id = $this->factory->post->create(); - $attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array( + $post_id = self::$factory->post->create(); + $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); @@ -760,7 +760,7 @@ EOF; // Make an image. $filename = DIR_TESTDATA . '/images/test-image-large.png'; - $id = $this->factory->attachment->create_upload_object( $filename ); + $id = self::$factory->attachment->create_upload_object( $filename ); $image = wp_get_attachment_metadata( $id ); diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index 00c5147ddd..e975d6a9fa 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -8,7 +8,7 @@ class Tests_Meta extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); + $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); $this->meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value' ); $this->delete_meta_id = add_metadata( 'user', $this->author->ID, 'delete_meta_key', 'delete_meta_value' ); } @@ -194,10 +194,10 @@ class Tests_Meta extends WP_UnitTestCase { * @ticket 16814 */ function test_meta_type_cast() { - $post_id1 = $this->factory->post->create(); + $post_id1 = self::$factory->post->create(); add_post_meta( $post_id1, 'num_as_longtext', 123 ); add_post_meta( $post_id1, 'num_as_longtext_desc', 10 ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'num_as_longtext', 99 ); add_post_meta( $post_id2, 'num_as_longtext_desc', 100 ); @@ -258,7 +258,7 @@ class Tests_Meta extends WP_UnitTestCase { } function test_meta_cache_order_asc() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $colors = array( 'red', 'blue', 'yellow', 'green' ); foreach ( $colors as $color ) add_post_meta( $post_id, 'color', $color ); diff --git a/tests/phpunit/tests/meta/slashes.php b/tests/phpunit/tests/meta/slashes.php index 2f402eb604..3f876d284a 100644 --- a/tests/phpunit/tests/meta/slashes.php +++ b/tests/phpunit/tests/meta/slashes.php @@ -8,8 +8,8 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) ); - $this->post_id = $this->factory->post->create(); + $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); + $this->post_id = self::$factory->post->create(); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); @@ -32,7 +32,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_edit_post() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); if ( function_exists( 'wp_add_post_meta' ) ) { $meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' ); $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' ); @@ -108,7 +108,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_add_post_meta() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); @@ -123,7 +123,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_update_post_meta() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); @@ -141,7 +141,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { if ( !function_exists( 'wp_add_post_meta' ) ) { return; } - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); wp_add_post_meta( $id, 'slash_test_1', $this->slash_1 ); wp_add_post_meta( $id, 'slash_test_2', $this->slash_3 ); wp_add_post_meta( $id, 'slash_test_3', $this->slash_4 ); @@ -159,7 +159,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { if ( !function_exists( 'wp_update_post_meta' ) ) { return; } - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); wp_update_post_meta( $id, 'slash_test_1', $this->slash_1 ); wp_update_post_meta( $id, 'slash_test_2', $this->slash_3 ); wp_update_post_meta( $id, 'slash_test_3', $this->slash_4 ); @@ -174,7 +174,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_add_comment_meta() { - $id = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); add_comment_meta( $id, 'slash_test_1', $this->slash_1 ); add_comment_meta( $id, 'slash_test_2', $this->slash_3 ); @@ -198,7 +198,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_update_comment_meta() { - $id = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); add_comment_meta( $id, 'slash_test_1', 'foo' ); add_comment_meta( $id, 'slash_test_2', 'foo' ); @@ -226,7 +226,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_add_user_meta() { - $id = $this->factory->user->create(); + $id = self::$factory->user->create(); add_user_meta( $id, 'slash_test_1', $this->slash_1 ); add_user_meta( $id, 'slash_test_2', $this->slash_3 ); @@ -250,7 +250,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { * */ function test_update_user_meta() { - $id = $this->factory->user->create(); + $id = self::$factory->user->create(); add_user_meta( $id, 'slash_test_1', 'foo' ); add_user_meta( $id, 'slash_test_2', 'foo' ); diff --git a/tests/phpunit/tests/multisite/bootstrap.php b/tests/phpunit/tests/multisite/bootstrap.php index 9daa024425..b9fb2adf7f 100644 --- a/tests/phpunit/tests/multisite/bootstrap.php +++ b/tests/phpunit/tests/multisite/bootstrap.php @@ -40,7 +40,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { ); foreach ( $ids as &$id ) { - $id = $this->factory->network->create( $id ); + $id = self::$factory->network->create( $id ); } unset( $id ); @@ -88,7 +88,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { ); foreach ( $ids as &$id ) { - $id = $this->factory->blog->create( $id ); + $id = self::$factory->blog->create( $id ); } unset( $id ); @@ -169,7 +169,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { ); foreach ( $network_ids as &$id ) { - $id = $this->factory->network->create( $id ); + $id = self::$factory->network->create( $id ); } unset( $id ); @@ -182,7 +182,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { ); foreach ( $ids as &$id ) { - $id = $this->factory->blog->create( $id ); + $id = self::$factory->blog->create( $id ); } unset( $id ); diff --git a/tests/phpunit/tests/multisite/getSpaceUsed.php b/tests/phpunit/tests/multisite/getSpaceUsed.php index 45135ba839..bd355cc13c 100644 --- a/tests/phpunit/tests/multisite/getSpaceUsed.php +++ b/tests/phpunit/tests/multisite/getSpaceUsed.php @@ -22,7 +22,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { } function test_get_space_used_switched_site() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); // Our comparison of space relies on an initial value of 0. If a previous test has failed or if the @@ -30,7 +30,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { // will be polluted. We create sites until an empty one is available. while ( 0 != get_space_used() ) { restore_current_blog(); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); } @@ -58,7 +58,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { function test_get_space_used_main_site() { $space_used = get_space_used(); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); // We don't rely on an initial value of 0 for space used, but should have a clean space available @@ -66,7 +66,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { // existing content directories in src. while ( 0 != get_space_used() ) { restore_current_blog(); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); } diff --git a/tests/phpunit/tests/multisite/ms-files-rewriting.php b/tests/phpunit/tests/multisite/ms-files-rewriting.php index ab2877bafd..611e8432ed 100644 --- a/tests/phpunit/tests/multisite/ms-files-rewriting.php +++ b/tests/phpunit/tests/multisite/ms-files-rewriting.php @@ -37,8 +37,8 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { $site = get_current_site(); - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) ); + $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $blog_id2 = self::$factory->blog->create( array( 'user_id' => $user_id ) ); $info = wp_upload_dir(); $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); @@ -67,7 +67,7 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { // Upload a file to the main site on the network. $file1 = wp_upload_bits( $filename, null, $contents ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); $file2 = wp_upload_bits( $filename, null, $contents ); diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 4e0d34a85e..01160ad096 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -37,7 +37,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase { * as the main network ID. */ function test_get_main_network_id_two_networks() { - $this->factory->network->create(); + self::$factory->network->create(); $this->assertEquals( 1, get_main_network_id() ); } @@ -49,7 +49,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase { function test_get_main_network_id_after_network_switch() { global $current_site; - $id = $this->factory->network->create(); + $id = self::$factory->network->create(); $current_site->id = (int) $id; @@ -65,7 +65,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase { */ function test_get_main_network_id_after_network_delete() { global $wpdb, $current_site; - $id = $this->factory->network->create(); + $id = self::$factory->network->create(); $current_site->id = (int) $id; $wpdb->query( "UPDATE {$wpdb->site} SET id=100 WHERE id=1" ); @@ -90,13 +90,13 @@ class Tests_Multisite_Network extends WP_UnitTestCase { $site_count_start = get_blog_count(); // false for large networks by default add_filter( 'enable_live_network_counts', '__return_false' ); - $this->factory->blog->create_many( 4 ); + self::$factory->blog->create_many( 4 ); // count only updated when cron runs, so unchanged $this->assertEquals( $site_count_start, (int) get_blog_count() ); add_filter( 'enable_live_network_counts', '__return_true' ); - $site_ids = $this->factory->blog->create_many( 4 ); + $site_ids = self::$factory->blog->create_many( 4 ); $this->assertEquals( $site_count_start + 9, (int) get_blog_count() ); @@ -211,7 +211,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase { // Only false for large networks as of 3.7 add_filter( 'enable_live_network_counts', '__return_false' ); - $this->factory->user->create( array( 'role' => 'administrator' ) ); + self::$factory->user->create( array( 'role' => 'administrator' ) ); $count = get_user_count(); // No change, cache not refreshed $this->assertEquals( $start_count, $count ); @@ -240,8 +240,8 @@ class Tests_Multisite_Network extends WP_UnitTestCase { $dashboard_blog = get_dashboard_blog(); $this->assertEquals( 1, $dashboard_blog->blog_id ); - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) ); + $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $blog_id = self::$factory->blog->create( array( 'user_id' => $user_id ) ); $this->assertInternalType( 'int', $blog_id ); // set the dashboard blog to another one diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index c119415ed2..0a51e6a43d 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -34,7 +34,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' ); $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $cap_key = wp_get_current_user()->cap_key; switch_to_blog( $blog_id ); @@ -74,7 +74,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { function test_created_site_details() { global $wpdb; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $this->assertInternalType( 'int', $blog_id ); $prefix = $wpdb->get_blog_prefix( $blog_id ); @@ -130,7 +130,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * When a site is flagged as 'deleted', its data should be cleared from cache. */ function test_data_in_cache_after_wpmu_delete_blog_drop_false() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $details = get_blog_details( $blog_id, false ); $key = md5( $details->domain . $details->path ); @@ -151,7 +151,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { function test_data_in_tables_after_wpmu_delete_blog_drop_false() { global $wpdb; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); // Delete the site without forcing a table drop. wpmu_delete_blog( $blog_id, false ); @@ -169,7 +169,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * When a site is fully deleted, its data should be cleared from cache. */ function test_data_in_cache_after_wpmu_delete_blog_drop_true() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $details = get_blog_details( $blog_id, false ); $key = md5( $details->domain . $details->path ); @@ -190,7 +190,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { function test_data_in_tables_after_wpmu_delete_blog_drop_true() { global $wpdb; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); // Delete the site and force a table drop. wpmu_delete_blog( $blog_id, true ); @@ -247,7 +247,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * The site count of a network should change when a site is flagged as 'deleted'. */ function test_network_count_after_wpmu_delete_blog_drop_false() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); // Delete the site without forcing a table drop. wpmu_delete_blog( $blog_id, false ); @@ -261,7 +261,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * The site count of a network should change when a site is fully deleted. */ function test_blog_count_after_wpmu_delete_blog_drop_true() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); // Delete the site and force a table drop. wpmu_delete_blog( $blog_id, true ); @@ -283,7 +283,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { // Upload a file to the main site on the network. $file1 = wp_upload_bits( $filename, null, $contents ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); $file2 = wp_upload_bits( $filename, null, $contents ); @@ -329,7 +329,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { */ function test_get_blog_details_when_site_does_not_exist() { // Create an unused site so that we can then assume an invalid site ID. - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $blog_id++; // Prime the cache for an invalid site. @@ -339,7 +339,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); // Create a site in the invalid site's place. - $this->factory->blog->create(); + self::$factory->blog->create(); // When a new site is created, its cache is cleared through refresh_blog_details. $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); @@ -370,7 +370,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); update_blog_details( $blog_id, array( 'spam' => 1 ) ); add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 ); @@ -394,7 +394,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 ); update_blog_status( $blog_id, 'spam', 1 ); @@ -417,7 +417,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 ); update_blog_status( $blog_id, 'archived', 1 ); @@ -440,7 +440,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); update_blog_details( $blog_id, array( 'archived' => 1 ) ); add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 ); @@ -463,7 +463,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 ); update_blog_status( $blog_id, 'deleted', 1 ); @@ -486,7 +486,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); update_blog_details( $blog_id, array( 'deleted' => 1 ) ); add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 ); @@ -510,7 +510,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 ); update_blog_status( $blog_id, 'mature', 1 ); @@ -533,7 +533,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); update_blog_details( $blog_id, array( 'mature' => 1 ) ); add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 ); @@ -557,7 +557,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 ); update_blog_status( $blog_id, 'public', 0 ); @@ -583,7 +583,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * @ticket 14511 */ function test_wp_get_sites_with_default_arguments() { - $this->factory->blog->create( array( 'site_id' => 2 ) ); + self::$factory->blog->create( array( 'site_id' => 2 ) ); $this->assertCount( 1, wp_get_sites() ); } @@ -599,7 +599,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * A network ID of null should query for all public sites on all networks. */ function test_wp_get_sites_with_network_id_null() { - $this->factory->blog->create( array( 'site_id' => 2 ) ); + self::$factory->blog->create( array( 'site_id' => 2 ) ); $this->assertCount( 2, wp_get_sites( array( 'network_id' => null ) ) ); } @@ -608,7 +608,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Expect only sites on the specified network ID to be returned. */ function test_wp_get_sites_with_specific_network_id() { - $this->factory->blog->create( array( 'site_id' => 2 ) ); + self::$factory->blog->create( array( 'site_id' => 2 ) ); $this->assertCount( 1, wp_get_sites( array( 'network_id' => 2 ) ) ); } @@ -617,7 +617,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Expect sites from both networks if both network IDs are specified. */ function test_wp_get_sites_with_multiple_network_ids() { - $this->factory->blog->create( array( 'site_id' => 2 ) ); + self::$factory->blog->create( array( 'site_id' => 2 ) ); $this->assertCount( 2, wp_get_sites( array( 'network_id' => array( 1, 2 ) ) ) ); } @@ -626,7 +626,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Queries for public or non public sites should work across all networks if network ID is null. */ function test_wp_get_sites_with_public_meta_on_all_networks() { - $this->factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) ); + self::$factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) ); $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => null ) ) ); $this->assertcount( 1, wp_get_sites( array( 'public' => 0, 'network_id' => null ) ) ); @@ -636,7 +636,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * If a network ID is specified, queries for public sites should be restricted to that network. */ function test_wp_get_sites_with_public_meta_restrict_to_one_network() { - $this->factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) ); + self::$factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) ); $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => 1 ) ) ); $this->assertCount( 0, wp_get_sites( array( 'public' => 1, 'network_id' => 2 ) ) ); @@ -647,7 +647,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { */ function test_wp_get_sites_limit_offset() { // Create 2 more sites (in addition to the default one) - $this->factory->blog->create_many( 2 ); + self::$factory->blog->create_many( 2 ); // Expect first 2 sites when using limit $this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) ); @@ -670,8 +670,8 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * @ticket 27952 */ function test_posts_count() { - $this->factory->post->create(); - $post2 = $this->factory->post->create(); + self::$factory->post->create(); + $post2 = self::$factory->post->create(); $this->assertEquals( 2, get_blog_details()->post_count ); wp_delete_post( $post2 ); @@ -701,7 +701,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { ); foreach ( $network_ids as &$id ) { - $id = $this->factory->network->create( $id ); + $id = self::$factory->network->create( $id ); } unset( $id ); @@ -714,7 +714,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { ); foreach ( $ids as &$id ) { - $id = $this->factory->blog->create( $id ); + $id = self::$factory->blog->create( $id ); } unset( $id ); @@ -772,7 +772,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * the blog ID is requested through get_blog_id_from_url(). */ function test_get_blog_id_from_url() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $details = get_blog_details( $blog_id, false ); $key = md5( $details->domain . $details->path ); @@ -785,7 +785,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Test the case insensitivity of the site lookup. */ function test_get_blog_id_from_url_is_case_insensitive() { - $blog_id = $this->factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) ); + $blog_id = self::$factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) ); $details = get_blog_details( $blog_id, false ); $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) ); @@ -795,7 +795,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Test the first and cached responses for a site that does not exist. */ function test_get_blog_id_from_url_that_does_not_exist() { - $blog_id = $this->factory->blog->create( array( 'path' => '/xyz' ) ); + $blog_id = self::$factory->blog->create( array( 'path' => '/xyz' ) ); $details = get_blog_details( $blog_id, false ); $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); @@ -807,7 +807,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`. */ function test_get_blog_id_from_url_with_deleted_flag() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $details = get_blog_details( $blog_id, false ); $key = md5( $details->domain . $details->path ); wpmu_delete_blog( $blog_id ); @@ -821,7 +821,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * -1 after an attempt at `get_blog_id_from_url()` is made. */ function test_get_blog_id_from_url_after_dropped() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $details = get_blog_details( $blog_id, false ); $key = md5( $details->domain . $details->path ); wpmu_delete_blog( $blog_id, true ); @@ -850,7 +850,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Test with a site ID other than the main site to ensure a false response. */ function test_is_main_site_is_false_with_other_blog_id() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $this->assertFalse( is_main_site( $blog_id ) ); } @@ -859,7 +859,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * Test with no passed ID after switching to another site ID. */ function test_is_main_site_is_false_after_switch_to_blog() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); $this->assertFalse( is_main_site() ); @@ -878,7 +878,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); $this->assertEquals( '', $info['error'] ); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); switch_to_blog( $blog_id ); $info = wp_upload_dir(); @@ -900,8 +900,8 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * another site on the network. */ function test_get_blog_post_from_another_site_on_network() { - $blog_id = $this->factory->blog->create(); - $post_id = $this->factory->post->create(); // Create a post on the primary site, ID 1. + $blog_id = self::$factory->blog->create(); + $post_id = self::$factory->post->create(); // Create a post on the primary site, ID 1. $post = get_post( $post_id ); switch_to_blog( $blog_id ); @@ -915,7 +915,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase { * If get_blog_post() is used on the same site, it should still work. */ function test_get_blog_post_from_same_site() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) ); } diff --git a/tests/phpunit/tests/multisite/updateBlogDetails.php b/tests/phpunit/tests/multisite/updateBlogDetails.php index 071eee4444..874d2bceec 100644 --- a/tests/phpunit/tests/multisite/updateBlogDetails.php +++ b/tests/phpunit/tests/multisite/updateBlogDetails.php @@ -25,7 +25,7 @@ class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { } function test_update_blog_details() { - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $result = update_blog_details( $blog_id, array( 'domain' => 'example.com', 'path' => 'my_path/' ) ); @@ -53,7 +53,7 @@ class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { global $test_action_counter; $test_action_counter = 0; - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); // Set an initial value of '1' for the flag when '0' is the flag value being tested. if ( '0' === $flag_value ) { diff --git a/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php b/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php index a368288d8c..50ddce79b4 100644 --- a/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php +++ b/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php @@ -63,13 +63,13 @@ class Tests_Multisite_WpmuValidateUserSignup extends WP_UnitTestCase { } public function test_should_fail_for_existing_user_name() { - $u = $this->factory->user->create( array( 'user_login' => 'foo123' ) ); + $u = self::$factory->user->create( array( 'user_login' => 'foo123' ) ); $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' ); $this->assertContains( 'user_name', $v['errors']->get_error_codes() ); } public function test_should_fail_for_existing_user_email() { - $u = $this->factory->user->create( array( 'user_email' => 'foo@example.com' ) ); + $u = self::$factory->user->create( array( 'user_email' => 'foo@example.com' ) ); $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' ); $this->assertContains( 'user_email', $v['errors']->get_error_codes() ); } diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 4c0771bec3..9c9275baaa 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -17,10 +17,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_request_json() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'display_name' => 'John Doe', ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_author' => $user->ID, 'post_title' => 'Hello World', ) ); @@ -60,10 +60,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_request_jsonp() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'display_name' => 'John Doe', ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_author' => $user->ID, 'post_title' => 'Hello World', ) ); @@ -83,10 +83,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_request_jsonp_invalid_callback() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'display_name' => 'John Doe', ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_author' => $user->ID, 'post_title' => 'Hello World', ) ); @@ -118,10 +118,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_request_xml() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'display_name' => 'John Doe', ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_author' => $user->ID, 'post_title' => 'Hello World', ) ); @@ -177,11 +177,11 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); } - $child = $this->factory->blog->create(); + $child = self::$factory->blog->create(); switch_to_blog( $child ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Hello Child Blog', ) ); @@ -207,7 +207,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) ); $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $url = get_permalink( $post_id ); $url_encoded = urlencode( $url ); diff --git a/tests/phpunit/tests/oembed/discovery.php b/tests/phpunit/tests/oembed/discovery.php index cad47cf813..ef78befcfa 100644 --- a/tests/phpunit/tests/oembed/discovery.php +++ b/tests/phpunit/tests/oembed/discovery.php @@ -12,7 +12,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { } function test_add_oembed_discovery_links_to_post() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue( 'is_single', 'is_singular' ); @@ -28,7 +28,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { } function test_add_oembed_discovery_links_to_page() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_type' => 'page' )); $this->go_to( get_permalink( $post_id ) ); @@ -46,9 +46,9 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { } function test_add_oembed_discovery_links_to_attachment() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $post_id, array( + $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', ) ); diff --git a/tests/phpunit/tests/oembed/getResponseData.php b/tests/phpunit/tests/oembed/getResponseData.php index 431707fe40..0891642c37 100644 --- a/tests/phpunit/tests/oembed/getResponseData.php +++ b/tests/phpunit/tests/oembed/getResponseData.php @@ -9,7 +9,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Some Post', ) ); @@ -33,11 +33,11 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { * Test get_oembed_response_data with an author. */ function test_get_oembed_response_data_author() { - $user_id = $this->factory->user->create( array( + $user_id = self::$factory->user->create( array( 'display_name' => 'John Doe', ) ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Some Post', 'post_author' => $user_id, ) ); @@ -61,7 +61,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { function test_get_oembed_response_link() { remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich' ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Some Post', ) ); @@ -81,7 +81,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_with_draft_post() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'draft', ) ); @@ -89,7 +89,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_with_scheduled_post() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'future', 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ), ) ); @@ -98,7 +98,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_with_private_post() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_status' => 'private', ) ); @@ -106,7 +106,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_maxwidth_too_high() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = get_oembed_response_data( $post, 1000 ); @@ -115,7 +115,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_maxwidth_too_low() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = get_oembed_response_data( $post, 100 ); @@ -124,7 +124,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_maxwidth_invalid() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $data = get_oembed_response_data( $post, '400;" DROP TABLES' ); @@ -138,9 +138,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_with_thumbnail() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array( + $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array( 'post_mime_type' => 'image/jpeg', ) ); set_post_thumbnail( $post, $attachment_id ); @@ -154,9 +154,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { } function test_get_oembed_response_data_for_attachment() { - $parent = $this->factory->post->create(); + $parent = self::$factory->post->create(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $post = $this->factory->attachment->create_object( $file, $parent, array( + $post = self::$factory->attachment->create_object( $file, $parent, array( 'post_mime_type' => 'image/jpeg', ) ); diff --git a/tests/phpunit/tests/oembed/headers.php b/tests/phpunit/tests/oembed/headers.php index 2ee7a4f18b..247e947b98 100644 --- a/tests/phpunit/tests/oembed/headers.php +++ b/tests/phpunit/tests/oembed/headers.php @@ -12,7 +12,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { $this->markTestSkipped( 'xdebug is required for this test' ); } - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Hello World', ) ); @@ -46,7 +46,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { $this->markTestSkipped( 'xdebug is required for this test' ); } - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Hello World', ) ); diff --git a/tests/phpunit/tests/oembed/postEmbedUrl.php b/tests/phpunit/tests/oembed/postEmbedUrl.php index 26e57ce433..1972bac098 100644 --- a/tests/phpunit/tests/oembed/postEmbedUrl.php +++ b/tests/phpunit/tests/oembed/postEmbedUrl.php @@ -12,7 +12,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase { function test_get_post_embed_url_with_pretty_permalinks() { update_option( 'permalink_structure', '/%postname%' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $embed_url = get_post_embed_url( $post_id ); @@ -22,7 +22,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase { } function test_get_post_embed_url_with_ugly_permalinks() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $embed_url = get_post_embed_url( $post_id ); diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php index 2c97d2cfaf..a2438d62b6 100644 --- a/tests/phpunit/tests/oembed/template.php +++ b/tests/phpunit/tests/oembed/template.php @@ -5,11 +5,11 @@ */ class Tests_Embed_Template extends WP_UnitTestCase { function test_oembed_output_post() { - $user = $this->factory->user->create_and_get( array( + $user = self::$factory->user->create_and_get( array( 'display_name' => 'John Doe', ) ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => $user->ID, 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', @@ -30,13 +30,13 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_post_with_thumbnail() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', ) ); $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $post_id, array( + $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', ) ); set_post_thumbnail( $post_id, $attachment_id ); @@ -72,9 +72,9 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_attachment() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array( + $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array( 'post_mime_type' => 'image/jpeg', 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', @@ -97,7 +97,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_draft_post() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', @@ -118,7 +118,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_scheduled_post() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', @@ -140,7 +140,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_private_post() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', @@ -161,10 +161,10 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_oembed_output_private_post_with_permissions() { - $user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); wp_set_current_user( $user_id ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', @@ -193,7 +193,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_wp_oembed_excerpt_more() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_content' => 'Foo Bar', ) ); @@ -214,15 +214,15 @@ class Tests_Embed_Template extends WP_UnitTestCase { function test_is_embed_post() { $this->assertFalse( is_embed() ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->go_to( get_post_embed_url( $post_id ) ); $this->assertTrue( is_embed() ); } function test_is_embed_attachment() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $post_id, array( + $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', ) ); $this->go_to( get_post_embed_url( $attachment_id ) ); @@ -240,7 +240,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { } function test_get_post_embed_html() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $expected = ''; diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index 9f82d84b3c..627b655d5d 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -98,10 +98,10 @@ class Tests_Multisite_Option extends WP_UnitTestCase { } function test_with_another_site() { - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); $this->assertInternalType( 'integer', $user_id ); - $blog_id = $this->factory->blog->create( array( + $blog_id = self::$factory->blog->create( array( 'user_id' => $user_id, 'meta' => array( 'public' => 1, diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php index 8512d1add9..f57c7963cb 100644 --- a/tests/phpunit/tests/option/networkOption.php +++ b/tests/phpunit/tests/option/networkOption.php @@ -11,7 +11,7 @@ if ( is_multisite() ) : */ class Tests_Option_NetworkOption extends WP_UnitTestCase { function test_add_network_option_not_available_on_other_network() { - $id = $this->factory->network->create(); + $id = self::$factory->network->create(); $option = rand_str(); $value = rand_str(); @@ -20,7 +20,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { } function test_add_network_option_available_on_same_network() { - $id = $this->factory->network->create(); + $id = self::$factory->network->create(); $option = rand_str(); $value = rand_str(); @@ -29,7 +29,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { } function test_delete_network_option_on_only_one_network() { - $id = $this->factory->network->create(); + $id = self::$factory->network->create(); $option = rand_str(); $value = rand_str(); diff --git a/tests/phpunit/tests/option/userSettings.php b/tests/phpunit/tests/option/userSettings.php index 1509fe2136..0c0aa3dc8e 100644 --- a/tests/phpunit/tests/option/userSettings.php +++ b/tests/phpunit/tests/option/userSettings.php @@ -5,7 +5,7 @@ class Tests_User_Settings extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->user_id = $this->factory->user->create( array( + $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 1078fc942a..17a93e4752 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -545,9 +545,9 @@ class Tests_Post extends WP_UnitTestCase { function test_get_page_by_path_priority() { global $wpdb; - $attachment = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); - $page = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); - $other_att = $this->factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); + $attachment = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); + $page = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); + $other_att = self::$factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) ); clean_post_cache( $page->ID ); @@ -565,7 +565,7 @@ class Tests_Post extends WP_UnitTestCase { } function test_wp_publish_post() { - $draft_id = $this->factory->post->create( array( 'post_status' => 'draft' ) ); + $draft_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); $post = get_post( $draft_id ); $this->assertEquals( 'draft', $post->post_status ); @@ -581,7 +581,7 @@ class Tests_Post extends WP_UnitTestCase { */ function test_wp_insert_post_and_wp_publish_post_with_future_date() { $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_status' => 'publish', 'post_date' => $future_date, ) ); @@ -641,7 +641,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 22883 */ function test_get_page_uri_with_stdclass_post_object() { - $post_id = $this->factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); + $post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); // Mimick an old stdClass post object, missing the ancestors field. $post_array = (object) get_post( $post_id, ARRAY_A ); @@ -664,8 +664,8 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 15963 */ function test_get_post_uri_check_orphan() { - $parent_id = $this->factory->post->create( array( 'post_name' => 'parent' ) ); - $child_id = $this->factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); + $parent_id = self::$factory->post->create( array( 'post_name' => 'parent' ) ); + $child_id = self::$factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); // check the parent for good measure $this->assertEquals( 'parent', get_page_uri( $parent_id ) ); @@ -683,8 +683,8 @@ class Tests_Post extends WP_UnitTestCase { */ function test_get_post_ancestors_within_loop() { global $post; - $parent_id = $this->factory->post->create(); - $post = $this->factory->post->create_and_get( array( 'post_parent' => $parent_id ) ); + $parent_id = self::$factory->post->create(); + $post = self::$factory->post->create_and_get( array( 'post_parent' => $parent_id ) ); $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) ); } @@ -692,7 +692,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 23474 */ function test_update_invalid_post_id() { - $post_id = $this->factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); + $post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); $post = get_post( $post_id, ARRAY_A ); $post['ID'] = 123456789; @@ -707,7 +707,7 @@ class Tests_Post extends WP_UnitTestCase { function test_parse_post_content_single_page() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 0, $multipage ); @@ -718,7 +718,7 @@ class Tests_Post extends WP_UnitTestCase { function test_parse_post_content_multi_page() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 1, $multipage ); @@ -729,7 +729,7 @@ class Tests_Post extends WP_UnitTestCase { function test_parse_post_content_remaining_single_page() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 0, $multipage ); @@ -740,7 +740,7 @@ class Tests_Post extends WP_UnitTestCase { function test_parse_post_content_remaining_multi_page() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 1, $multipage ); @@ -754,7 +754,7 @@ class Tests_Post extends WP_UnitTestCase { */ function test_parse_post_content_starting_with_nextpage() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0Page 1Page 2Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 1, $multipage ); @@ -768,7 +768,7 @@ class Tests_Post extends WP_UnitTestCase { */ function test_parse_post_content_starting_with_nextpage_multi() { global $multipage, $pages, $numpages; - $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); $this->assertEquals( 0, $multipage ); @@ -809,7 +809,7 @@ class Tests_Post extends WP_UnitTestCase { function test_wp_count_posts() { $post_type = rand_str(20); register_post_type( $post_type ); - $this->factory->post->create( array( + self::$factory->post->create( array( 'post_type' => $post_type, 'post_author' => self::$editor_id ) ); @@ -822,7 +822,7 @@ class Tests_Post extends WP_UnitTestCase { function test_wp_count_posts_filtered() { $post_type = rand_str(20); register_post_type( $post_type ); - $this->factory->post->create_many( 3, array( + self::$factory->post->create_many( 3, array( 'post_type' => $post_type, 'post_author' => self::$editor_id ) ); @@ -842,7 +842,7 @@ class Tests_Post extends WP_UnitTestCase { } function test_wp_count_posts_insert_invalidation() { - $post_ids = $this->factory->post->create_many( 3 ); + $post_ids = self::$factory->post->create_many( 3 ); $initial_counts = wp_count_posts(); $key = array_rand( $post_ids ); @@ -860,7 +860,7 @@ class Tests_Post extends WP_UnitTestCase { } function test_wp_count_posts_trash_invalidation() { - $post_ids = $this->factory->post->create_many( 3 ); + $post_ids = self::$factory->post->create_many( 3 ); $initial_counts = wp_count_posts(); $key = array_rand( $post_ids ); @@ -881,7 +881,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 13771 */ function test_get_the_date_with_id_returns_correct_time() { - $post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); } @@ -899,7 +899,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 28310 */ function test_get_the_time_with_id_returns_correct_time() { - $post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); } @@ -917,7 +917,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 28310 */ function test_get_post_time_with_id_returns_correct_time() { - $post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); } @@ -935,7 +935,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 28310 */ function test_get_post_modified_time_with_id_returns_correct_time() { - $post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); } @@ -973,7 +973,7 @@ class Tests_Post extends WP_UnitTestCase { register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) ); register_taxonomy( $tax, $post_type ); - $post = $this->factory->post->create( array( 'post_type' => $post_type ) ); + $post = self::$factory->post->create( array( 'post_type' => $post_type ) ); wp_set_object_terms( $post, rand_str(), $tax ); $wp_tag_cloud = wp_tag_cloud( array( @@ -1015,7 +1015,7 @@ class Tests_Post extends WP_UnitTestCase { require_once( ABSPATH . '/wp-admin/includes/post.php' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $data = array( 'post_ID' => $post_id, @@ -1043,7 +1043,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 31168 */ function test_wp_insert_post_default_comment_ping_status_open() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => self::$editor_id, 'post_status' => 'public', 'post_content' => rand_str(), @@ -1059,7 +1059,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 31168 */ function test_wp_insert_post_page_default_comment_ping_status_closed() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => self::$editor_id, 'post_status' => 'public', 'post_content' => rand_str(), @@ -1078,7 +1078,7 @@ class Tests_Post extends WP_UnitTestCase { function test_wp_insert_post_cpt_default_comment_ping_status_open() { $post_type = rand_str(20); register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => self::$editor_id, 'post_status' => 'public', 'post_content' => rand_str(), @@ -1098,7 +1098,7 @@ class Tests_Post extends WP_UnitTestCase { function test_wp_insert_post_cpt_default_comment_ping_status_closed() { $post_type = rand_str(20); register_post_type( $post_type ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => self::$editor_id, 'post_status' => 'public', 'post_content' => rand_str(), @@ -1127,7 +1127,7 @@ class Tests_Post extends WP_UnitTestCase { $this->assertTrue( current_user_can( 'edit_published_posts' ) ); // Create a sticky post. - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Will be changed', 'post_content' => 'Will be changed', ) ); @@ -1156,7 +1156,7 @@ class Tests_Post extends WP_UnitTestCase { */ function test_user_without_publish_cannot_affect_sticky_with_edit_post() { // Create a sticky post. - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_title' => 'Will be changed', 'post_content' => 'Will be changed', ) ); @@ -1191,7 +1191,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 32585 */ public function test_wp_insert_post_author_zero() { - $post_id = $this->factory->post->create( array( 'post_author' => 0 ) ); + $post_id = self::$factory->post->create( array( 'post_author' => 0 ) ); $this->assertEquals( 0, get_post( $post_id )->post_author ); } @@ -1200,7 +1200,7 @@ class Tests_Post extends WP_UnitTestCase { * @ticket 32585 */ public function test_wp_insert_post_author_null() { - $post_id = $this->factory->post->create( array( 'post_author' => null ) ); + $post_id = self::$factory->post->create( array( 'post_author' => null ) ); $this->assertEquals( self::$editor_id, get_post( $post_id )->post_author ); } diff --git a/tests/phpunit/tests/post/filtering.php b/tests/phpunit/tests/post/filtering.php index 57c4ed7b72..faabf28ab7 100644 --- a/tests/phpunit/tests/post/filtering.php +++ b/tests/phpunit/tests/post/filtering.php @@ -31,7 +31,7 @@ EOF; no such tag EOF; - $id = $this->factory->post->create( array( 'post_content' => $content ) ); + $id = self::$factory->post->create( array( 'post_content' => $content ) ); $post = get_post($id); $this->assertEquals( $expected, $post->post_content ); @@ -48,7 +48,7 @@ EOF; italics EOF; - $id = $this->factory->post->create( array( 'post_content' => $content ) ); + $id = self::$factory->post->create( array( 'post_content' => $content ) ); $post = get_post($id); $this->assertEquals( $expected, $post->post_content ); @@ -65,7 +65,7 @@ EOF; EOF; - $id = $this->factory->post->create( array( 'post_content' => $content ) ); + $id = self::$factory->post->create( array( 'post_content' => $content ) ); $post = get_post($id); $this->assertEquals( $expected, $post->post_content ); @@ -84,7 +84,7 @@ EOF; EOF; - $id = $this->factory->post->create( array( 'post_content' => $content ) ); + $id = self::$factory->post->create( array( 'post_content' => $content ) ); $post = get_post($id); $this->assertEquals( $expected, $post->post_content ); @@ -104,7 +104,7 @@ that's continued after the jump breaks the graf

EOF; - $id = $this->factory->post->create( array( 'post_content' => $content ) ); + $id = self::$factory->post->create( array( 'post_content' => $content ) ); $post = get_post($id); $this->assertEquals( $content, $post->post_content ); diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index 705a2f361f..ecb9bf2cb9 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -9,7 +9,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { } function test_set_get_post_format_for_post() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $format = get_post_format( $post_id ); $this->assertFalse( $format ); @@ -37,7 +37,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { * @ticket 22473 */ function test_set_get_post_format_for_page() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $format = get_post_format( $post_id ); $this->assertFalse( $format ); @@ -69,7 +69,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { } function test_has_format() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->assertFalse( has_post_format( 'standard', $post_id ) ); $this->assertFalse( has_post_format( '', $post_id ) ); @@ -111,11 +111,11 @@ $href $commentary DATA; - $link_post_id = $this->factory->post->create( array( 'post_content' => $link ) ); + $link_post_id = self::$factory->post->create( array( 'post_content' => $link ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) ); $this->assertEquals( false, $content_link ); - $link_with_post_id = $this->factory->post->create( array( 'post_content' => $link_with_commentary ) ); + $link_with_post_id = self::$factory->post->create( array( 'post_content' => $link_with_commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); $this->assertEquals( false, $content_link ); @@ -125,20 +125,20 @@ DATA; $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); $this->assertEquals( false, $content_link ); - $empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) ); + $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); $this->assertEquals( false, $content_link ); - $comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) ); + $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); $this->assertEquals( false, $content_link ); // Now with an href - $href_post_id = $this->factory->post->create( array( 'post_content' => $href ) ); + $href_post_id = self::$factory->post->create( array( 'post_content' => $href ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) ); $this->assertEquals( $link, $content_link ); - $href_with_post_id = $this->factory->post->create( array( 'post_content' => $href_with_commentary ) ); + $href_with_post_id = self::$factory->post->create( array( 'post_content' => $href_with_commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); $this->assertEquals( $link, $content_link ); @@ -148,11 +148,11 @@ DATA; $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); $this->assertEquals( $link, $content_link ); - $empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) ); + $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); $this->assertEquals( false, $content_link ); - $comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) ); + $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); $this->assertEquals( false, $content_link ); } diff --git a/tests/phpunit/tests/post/getBodyClass.php b/tests/phpunit/tests/post/getBodyClass.php index 38686b30b5..1592ad1a5f 100644 --- a/tests/phpunit/tests/post/getBodyClass.php +++ b/tests/phpunit/tests/post/getBodyClass.php @@ -9,16 +9,16 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create(); + $this->post_id = self::$factory->post->create(); } /** * @ticket 30883 */ public function test_with_utf8_category_slugs() { - $cat_id1 = $this->factory->category->create( array( 'name' => 'Первая рубрика' ) ); - $cat_id2 = $this->factory->category->create( array( 'name' => 'Вторая рубрика' ) ); - $cat_id3 = $this->factory->category->create( array( 'name' => '25кадр' ) ); + $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) ); + $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) ); + $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' ); $this->go_to( home_url( "?cat=$cat_id1" ) ); @@ -35,9 +35,9 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase { * @ticket 30883 */ public function test_with_utf8_tag_slugs() { - $tag_id1 = $this->factory->tag->create( array( 'name' => 'Первая метка' ) ); - $tag_id2 = $this->factory->tag->create( array( 'name' => 'Вторая метка' ) ); - $tag_id3 = $this->factory->tag->create( array( 'name' => '25кадр' ) ); + $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) ); + $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) ); + $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' ); $tag1 = get_term( $tag_id1, 'post_tag' ); @@ -59,9 +59,9 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase { */ public function test_with_utf8_term_slugs() { register_taxonomy( 'wptests_tax', 'post' ); - $term_id1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); - $term_id2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); - $term_id3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); + $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); + $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); + $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' ); $term1 = get_term( $term_id1, 'wptests_tax' ); diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index d6932812b4..a9cf113222 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -15,7 +15,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { function test_get_pages_cache() { global $wpdb; - $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) ); + self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); wp_cache_delete( 'last_changed', 'posts' ); $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); @@ -99,7 +99,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 20376 */ function test_get_pages_meta() { - $posts = $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) ); + $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); add_post_meta( $posts[0], 'some-meta-key', '0' ); add_post_meta( $posts[1], 'some-meta-key', '' ); add_post_meta( $posts[2], 'some-meta-key', '1' ); @@ -116,7 +116,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { $page_ids = array(); foreach ( range( 1, 20 ) as $i ) - $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $page_ids[] = self::$factory->post->create( array( 'post_type' => 'page' ) ); $inc = array_slice( $page_ids, 0, 10 ); sort( $inc ); @@ -138,10 +138,10 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 9470 */ function test_get_pages_parent() { - $page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); - $page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); - $page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); + $page_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); + $page_id3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); + $page_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) ); $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); @@ -166,7 +166,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 22389 */ function test_wp_dropdown_pages() { - $this->factory->post->create_many( 5, array( 'post_type' => 'page' ) ); + self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) ); preg_match_all( '#factory->post->create(); - $child_ids = $this->factory->post->create_many( 5, array( 'post_parent' => $post_id ) ); + $post_id = self::$factory->post->create(); + $child_ids = self::$factory->post->create_many( 5, array( 'post_parent' => $post_id ) ); $post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) ); $this->assertEqualSets( $child_ids, $post_ids ); @@ -189,10 +189,10 @@ class Tests_Post_getPages extends WP_UnitTestCase { */ function test_get_pages_hierarchical_and_no_parent() { global $wpdb; - $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) ); + $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) ); $pages = get_pages(); // Defaults: hierarchical = true, parent = -1 $pages_default_args = get_pages( array( 'hierarchical' => true, 'parent' => -1 ) ); @@ -218,10 +218,10 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 18701 */ public function test_get_pages_hierarchical_empty_child_of() { - $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); $pages = get_pages(); // Defaults: hierarchical = true, child_of = '', parent = -1 $default_args = get_pages( array( @@ -252,10 +252,10 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 18701 */ public function test_get_pages_non_hierarchical_empty_child_of() { - $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); $pages = get_pages( array( 'hierarchical' => false ) ); // child_of = '', parent = -1 @@ -278,11 +278,11 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 18701 */ public function test_get_pages_hierarchical_non_empty_child_of() { - $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); - $page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); + $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); $pages = get_pages( array( 'child_of' => $page_1 ) ); // Defaults: hierarchical = true, parent = -1. @@ -306,11 +306,11 @@ class Tests_Post_getPages extends WP_UnitTestCase { * @ticket 18701 */ public function test_get_pages_non_hierarchical_non_empty_child_of() { - $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); - $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); - $page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); + $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); + $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); $pages = get_pages( array( 'hierarchical' => false, 'child_of' => $page_1 ) ); @@ -338,7 +338,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { $type = 'taco'; register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) ); - $posts = $this->factory->post->create_many( 2, array( 'post_type' => $type ) ); + $posts = self::$factory->post->create_many( 2, array( 'post_type' => $type ) ); $post_id = reset( $posts ); $this->go_to( "/?p=$post_id&post_type=$type" ); @@ -360,10 +360,10 @@ class Tests_Post_getPages extends WP_UnitTestCase { } function test_exclude_tree() { - $post_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $post_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) ); - $post_id3 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $post_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) ); + $post_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) ); + $post_id3 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $post_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) ); $all = get_pages(); @@ -384,8 +384,8 @@ class Tests_Post_getPages extends WP_UnitTestCase { $exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) ); $this->assertCount( 0, $exclude5 ); - $post_id5 = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $post_id6 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) ); + $post_id5 = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $post_id6 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) ); $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) ); $this->assertCount( 2, $exclude6 ); diff --git a/tests/phpunit/tests/post/getPostClass.php b/tests/phpunit/tests/post/getPostClass.php index 8d29c405da..81b96fac01 100644 --- a/tests/phpunit/tests/post/getPostClass.php +++ b/tests/phpunit/tests/post/getPostClass.php @@ -9,7 +9,7 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create(); + $this->post_id = self::$factory->post->create(); } public function test_with_tags() { @@ -22,7 +22,7 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { } public function test_with_categories() { - $cats = $this->factory->category->create_many( 2 ); + $cats = self::$factory->category->create_many( 2 ); wp_set_post_terms( $this->post_id, $cats, 'category' ); $cat0 = get_term( $cats[0], 'category' ); @@ -57,9 +57,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { * @ticket 30883 */ public function test_with_utf8_category_slugs() { - $cat_id1 = $this->factory->category->create( array( 'name' => 'Первая рубрика' ) ); - $cat_id2 = $this->factory->category->create( array( 'name' => 'Вторая рубрика' ) ); - $cat_id3 = $this->factory->category->create( array( 'name' => '25кадр' ) ); + $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) ); + $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) ); + $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' ); $found = get_post_class( '', $this->post_id ); @@ -73,9 +73,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { * @ticket 30883 */ public function test_with_utf8_tag_slugs() { - $tag_id1 = $this->factory->tag->create( array( 'name' => 'Первая метка' ) ); - $tag_id2 = $this->factory->tag->create( array( 'name' => 'Вторая метка' ) ); - $tag_id3 = $this->factory->tag->create( array( 'name' => '25кадр' ) ); + $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) ); + $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) ); + $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' ); $found = get_post_class( '', $this->post_id ); @@ -90,9 +90,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { */ public function test_with_utf8_term_slugs() { register_taxonomy( 'wptests_tax', 'post' ); - $term_id1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); - $term_id2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); - $term_id3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); + $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); + $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); + $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' ); $found = get_post_class( '', $this->post_id ); diff --git a/tests/phpunit/tests/post/getPostsByAuthorSql.php b/tests/phpunit/tests/post/getPostsByAuthorSql.php index 7cd1aa65ef..0d0ff4015f 100644 --- a/tests/phpunit/tests/post/getPostsByAuthorSql.php +++ b/tests/phpunit/tests/post/getPostsByAuthorSql.php @@ -59,7 +59,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user(){ $current_user = get_current_user_id(); - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); wp_set_current_user( $u ); $maybe_string = get_posts_by_author_sql( 'post', true, $u, true ); @@ -70,7 +70,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_public_only_should_default_to_false(){ $current_user = get_current_user_id(); - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); wp_set_current_user( $u ); $this->assertSame( get_posts_by_author_sql( 'post', true, $u, false ), get_posts_by_author_sql( 'post', true, $u ) ); @@ -80,7 +80,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author(){ $current_user = get_current_user_id(); - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); wp_set_current_user( $u ); $maybe_string = get_posts_by_author_sql( 'post', true, $u, false ); @@ -91,8 +91,8 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author(){ $current_user = get_current_user_id(); - $u1 = $this->factory->user->create(); - $u2 = $this->factory->user->create(); + $u1 = self::$factory->user->create(); + $u2 = self::$factory->user->create(); wp_set_current_user( $u1 ); $maybe_string = get_posts_by_author_sql( 'post', true, $u2, false ); @@ -103,7 +103,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided(){ $current_user = get_current_user_id(); - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); wp_set_current_user( $u ); $maybe_string = get_posts_by_author_sql( 'post', true, $u, false ); @@ -115,7 +115,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){ $current_user = get_current_user_id(); - $u = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $u = self::$factory->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $u ); $maybe_string = get_posts_by_author_sql( 'post', true, null, false ); @@ -130,7 +130,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) ); register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) ); $current_user = get_current_user_id(); - $u = $this->factory->user->create( array( 'role' => 'editor' ) ); + $u = self::$factory->user->create( array( 'role' => 'editor' ) ); $editor_role = get_role('editor'); $editor_role->add_cap( 'read_private_baz' ); wp_set_current_user( $u ); diff --git a/tests/phpunit/tests/post/listPages.php b/tests/phpunit/tests/post/listPages.php index f2c54aa766..2b89bb2e9d 100644 --- a/tests/phpunit/tests/post/listPages.php +++ b/tests/phpunit/tests/post/listPages.php @@ -27,15 +27,15 @@ class Tests_List_Pages extends WP_UnitTestCase { global $wpdb; $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' ); $pages = array(); - $this->factory->user->create(); - $pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) ); - $pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) ); - $pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) ); + self::$factory->user->create(); + $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) ); + $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) ); + $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) ); foreach ( $pages as $page ) { - $this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) ); - $this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) ); - $this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) ); + $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) ); + $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) ); + $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) ); } } diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 2fb883f53c..e4e4d35502 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -8,7 +8,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author = new WP_User( $this->factory->user->create( array( 'role' => 'editor' ) ) ); + $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); $post = array( 'post_author' => $this->author->ID, diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 7dede5af56..40ac706e47 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -16,11 +16,11 @@ class Test_Nav_Menus extends WP_UnitTestCase { } function test_wp_get_associated_nav_menu_items() { - $tag_id = $this->factory->tag->create(); - $cat_id = $this->factory->category->create(); - $post_id = $this->factory->post->create(); - $post_2_id = $this->factory->post->create(); - $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $tag_id = self::$factory->tag->create(); + $cat_id = self::$factory->category->create(); + $post_id = self::$factory->post->create(); + $post_2_id = self::$factory->post->create(); + $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 'menu-item-type' => 'taxonomy', @@ -107,7 +107,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { $this->assertEquals( 'Wordpress.org', $custom_item->title ); // Update the orphan with an associated nav menu - wp_update_nav_menu_item( $this->menu_id, $custom_item_id, array( + wp_update_nav_menu_item( $this->menu_id, $custom_item_id, array( 'menu-item-title' => 'WordPress.org', ) ); $menu_items = wp_get_nav_menu_items( $this->menu_id ); @@ -119,8 +119,8 @@ class Test_Nav_Menus extends WP_UnitTestCase { public function test_wp_get_nav_menu_items_with_taxonomy_term() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $child_terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $child_terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) ); $term_menu_item = wp_update_nav_menu_item( $this->menu_id, 0, array( 'menu-item-type' => 'taxonomy', @@ -140,7 +140,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { * @ticket 29460 */ function test_orderby_name_by_default() { - // We are going to create a random number of menus (min 2, max 10) + // We are going to create a random number of menus (min 2, max 10) $menus_no = rand( 2, 10 ); for ( $i = 0; $i <= $menus_no; $i++ ) { @@ -148,14 +148,14 @@ class Test_Nav_Menus extends WP_UnitTestCase { } // This is the expected array of menu names - $expected_nav_menus_names = wp_list_pluck( + $expected_nav_menus_names = wp_list_pluck( get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'name' ) ), 'name' ); // And this is what we got when calling wp_get_nav_menus() $nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' ); - + $this->assertEquals( $nav_menus_names, $expected_nav_menus_names ); } } diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index e98098d2ac..048e6b806a 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -6,7 +6,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { function test_get_post() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); $post = get_post( $id ); $this->assertInstanceOf( 'WP_Post', $post ); @@ -67,9 +67,9 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_post_ancestors() { - $parent_id = $this->factory->post->create(); - $child_id = $this->factory->post->create(); - $grandchild_id = $this->factory->post->create(); + $parent_id = self::$factory->post->create(); + $child_id = self::$factory->post->create(); + $grandchild_id = self::$factory->post->create(); $updated = wp_update_post( array( 'ID' => $child_id, 'post_parent' => $parent_id ) ); $this->assertEquals( $updated, $child_id ); $updated = wp_update_post( array( 'ID' => $grandchild_id, 'post_parent' => $child_id ) ); @@ -99,7 +99,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_post_category_property() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $post = get_post( $post_id ); $this->assertInternalType( 'array', $post->post_category ); @@ -118,7 +118,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_tags_input_property() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $post = get_post( $post_id ); $this->assertInternalType( 'array', $post->tags_input ); @@ -135,7 +135,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_page_template_property() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $post = get_post( $post_id ); $this->assertInternalType( 'string', $post->page_template ); @@ -155,7 +155,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_post_filter() { - $post = get_post( $this->factory->post->create( array( + $post = get_post( self::$factory->post->create( array( 'post_title' => "Mary's home" ) ) ); @@ -178,7 +178,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_post_identity() { - $post = get_post( $this->factory->post->create() ); + $post = get_post( self::$factory->post->create() ); $post->foo = 'bar'; @@ -187,7 +187,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { } function test_get_post_array() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); $post = get_post( $id, ARRAY_A ); @@ -202,7 +202,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { function test_get_post_cache() { global $wpdb; - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); wp_cache_delete( $id, 'posts' ); // get_post( stdClass ) should not prime the cache diff --git a/tests/phpunit/tests/post/output.php b/tests/phpunit/tests/post/output.php index fcac5e4fed..d3c0fb4e21 100644 --- a/tests/phpunit/tests/post/output.php +++ b/tests/phpunit/tests/post/output.php @@ -41,7 +41,7 @@ class Tests_Post_Output extends WP_UnitTestCase { This is the body. EOF; - $post_id = $this->factory->post->create( compact( 'post_content' ) ); + $post_id = self::$factory->post->create( compact( 'post_content' ) ); $expected = <<This is the excerpt.
@@ -76,7 +76,7 @@ baz = bar EOF; - $post_id = $this->factory->post->create( compact( 'post_content' ) ); + $post_id = self::$factory->post->create( compact( 'post_content' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertTrue( is_single() ); $this->assertTrue( have_posts() ); @@ -114,7 +114,7 @@ EOF; EOF; - $post_id = $this->factory->post->create( compact( 'post_content' ) ); + $post_id = self::$factory->post->create( compact( 'post_content' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertTrue( is_single() ); $this->assertTrue( have_posts() ); @@ -136,7 +136,7 @@ EOF;

Mariat, D., Taourit, S., Guérin, G. (2003). . Genetics Selection Evolution, 35(1), 119-133. DOI: 10.1051/gse:2002039

EOF; - $post_id = $this->factory->post->create( compact( 'post_content' ) ); + $post_id = self::$factory->post->create( compact( 'post_content' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertTrue( is_single() ); $this->assertTrue( have_posts() ); @@ -160,7 +160,7 @@ EOF;

foo

EOF; - $post_id = $this->factory->post->create( compact( 'post_content' ) ); + $post_id = self::$factory->post->create( compact( 'post_content' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertTrue( is_single() ); $this->assertTrue( have_posts() ); diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 904ab9f3cf..5b86d21691 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -11,9 +11,9 @@ class Tests_Post_Query extends WP_UnitTestCase { function test_category__and_var() { $q = new WP_Query(); - $term_id = $this->factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); - $term_id2 = $this->factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) ); - $post_id = $this->factory->post->create(); + $term_id = self::$factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); + $term_id2 = self::$factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) ); + $post_id = self::$factory->post->create(); wp_set_post_categories( $post_id, $term_id ); @@ -41,8 +41,8 @@ class Tests_Post_Query extends WP_UnitTestCase { * @group taxonomy */ function test_empty_category__in() { - $cat_id = $this->factory->category->create(); - $post_id = $this->factory->post->create(); + $cat_id = self::$factory->category->create(); + $post_id = self::$factory->post->create(); wp_set_post_categories( $post_id, $cat_id ); $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) ); @@ -71,7 +71,7 @@ class Tests_Post_Query extends WP_UnitTestCase { */ function test_the_posts_filter() { // Create posts and clear their caches. - $post_ids = $this->factory->post->create_many( 4 ); + $post_ids = self::$factory->post->create_many( 4 ); foreach ( $post_ids as $post_id ) clean_post_cache( $post_id ); @@ -115,19 +115,19 @@ class Tests_Post_Query extends WP_UnitTestCase { } function test_post__in_ordering() { - $post_id1 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); - $post_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); - $post_id3 = $this->factory->post->create( array( + $post_id1 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); + $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); + $post_id3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id2, 'menu_order' => rand( 1, 100 ) ) ); - $post_id4 = $this->factory->post->create( array( + $post_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id2, 'menu_order' => rand( 1, 100 ) ) ); - $post_id5 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); + $post_id5 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); $ordered = array( $post_id2, $post_id4, $post_id3, $post_id1, $post_id5 ); @@ -140,26 +140,26 @@ class Tests_Post_Query extends WP_UnitTestCase { } function test_post__in_attachment_ordering() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $att_ids = array(); $file = DIR_TESTDATA . '/images/canola.jpg'; - $att_ids[1] = $this->factory->attachment->create_object( $file, $post_id, array( + $att_ids[1] = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', 'menu_order' => rand( 1, 100 ) ) ); - $att_ids[2] = $this->factory->attachment->create_object( $file, $post_id, array( + $att_ids[2] = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', 'menu_order' => rand( 1, 100 ) ) ); - $att_ids[3] = $this->factory->attachment->create_object( $file, $post_id, array( + $att_ids[3] = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', 'menu_order' => rand( 1, 100 ) ) ); - $att_ids[4] = $this->factory->attachment->create_object( $file, $post_id, array( + $att_ids[4] = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', 'menu_order' => rand( 1, 100 ) ) ); - $att_ids[5] = $this->factory->attachment->create_object( $file, $post_id, array( + $att_ids[5] = self::$factory->attachment->create_object( $file, $post_id, array( 'post_mime_type' => 'image/jpeg', 'menu_order' => rand( 1, 100 ) ) ); @@ -311,10 +311,10 @@ class Tests_Post_Query extends WP_UnitTestCase { public function test_post_name__in() { $q = new WP_Query(); - $post_ids[0] = $this->factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) ); - $post_ids[1] = $this->factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) ); - $post_ids[2] = $this->factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) ); - $post_ids[3] = $this->factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) ); + $post_ids[0] = self::$factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) ); + $post_ids[1] = self::$factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) ); + $post_ids[2] = self::$factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) ); + $post_ids[3] = self::$factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) ); $requested = array( $post_ids[0], $post_ids[3] ); $q->query( array( diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index a20c1d99db..aaba1e292a 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -144,7 +144,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 16847 */ function test_revision_view_caps_post() { - $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); @@ -166,7 +166,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 16847 */ function test_revision_restore_caps_post() { - $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); @@ -186,7 +186,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 16847 */ function test_revision_diff_caps_post() { - $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) ); @@ -214,7 +214,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { 'supports' => array( 'revisions' ), ) ); - $post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); @@ -247,7 +247,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { $editor_user->add_cap( 'edit_published_events' ); //create a post as Editor - $post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); @@ -282,7 +282,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { $old_id = get_current_user_id(); wp_set_current_user( self::$editor_user_id ); - $post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); @@ -314,7 +314,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { 'supports' => array( 'revisions' ), ) ); - $post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); + $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) ); @@ -337,7 +337,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { function test_wp_get_post_revisions_should_order_by_post_date() { global $wpdb; - $post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); $post = (array) $post; $post_revision_fields = _wp_post_revision_fields( $post ); @@ -365,7 +365,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 26042 */ function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() { - $post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); + $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); $post = (array) $post; $post_revision_fields = _wp_post_revision_fields( $post ); diff --git a/tests/phpunit/tests/post/slashes.php b/tests/phpunit/tests/post/slashes.php index ee93abb7ad..0d3465ff66 100644 --- a/tests/phpunit/tests/post/slashes.php +++ b/tests/phpunit/tests/post/slashes.php @@ -8,7 +8,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); @@ -33,7 +33,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { * */ function test_edit_post() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); $_POST = array(); $_POST['post_ID'] = $id; @@ -102,7 +102,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { * */ function test_wp_update_post() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); wp_update_post(array( 'ID' => $id, diff --git a/tests/phpunit/tests/post/template.php b/tests/phpunit/tests/post/template.php index 5c80082510..89b214f1fe 100644 --- a/tests/phpunit/tests/post/template.php +++ b/tests/phpunit/tests/post/template.php @@ -8,7 +8,7 @@ class Tests_Post_Template extends WP_UnitTestCase { function test_wp_link_pages() { $contents = array( 'One', 'Two', 'Three' ); $content = join( '', $contents ); - $post_id = $this->factory->post->create( array( 'post_content' => $content ) ); + $post_id = self::$factory->post->create( array( 'post_content' => $content ) ); $this->go_to( '?p=' . $post_id ); @@ -81,15 +81,19 @@ class Tests_Post_Template extends WP_UnitTestCase { $this->assertEmpty( $none ); $bump = '   '; - $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $child_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) ); - $grandchild_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $child_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) ); + $grandchild_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) ); + + $title1 = get_post( $page_id )->post_title; + $title2 = get_post( $child_id )->post_title; + $title3 = get_post( $grandchild_id )->post_title; $lineage =<< - - - + + + LINEAGE; @@ -99,7 +103,7 @@ LINEAGE; $depth =<< - + DEPTH; @@ -110,7 +114,7 @@ DEPTH; $option_none =<< - + NONE; @@ -124,7 +128,7 @@ NONE; NO; @@ -139,7 +143,7 @@ NO; * @ticket 12494 */ public function test_wp_dropdown_pages_value_field_should_default_to_ID() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', ) ); @@ -155,7 +159,7 @@ NO; * @ticket 12494 */ public function test_wp_dropdown_pages_value_field_ID() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', ) ); @@ -171,7 +175,7 @@ NO; * @ticket 12494 */ public function test_wp_dropdown_pages_value_field_post_name() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'foo', ) ); @@ -188,7 +192,7 @@ NO; * @ticket 12494 */ public function test_wp_dropdown_pages_value_field_should_fall_back_on_ID_when_an_invalid_value_is_provided() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'foo', ) ); @@ -205,7 +209,7 @@ NO; * @ticket 30082 */ public function test_wp_dropdown_pages_should_not_contain_class_attribute_when_no_class_is_passed() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'foo', ) ); @@ -221,7 +225,7 @@ NO; * @ticket 30082 */ public function test_wp_dropdown_pages_should_obey_class_parameter() { - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'foo', ) ); @@ -238,7 +242,7 @@ NO; * @ticket 31389 */ public function test_get_page_template_slug_by_id() { - $page_id = $this->factory->post->create( array( + $page_id = self::$factory->post->create( array( 'post_type' => 'page', ) ); @@ -255,7 +259,7 @@ NO; * @ticket 31389 */ public function test_get_page_template_slug_from_loop() { - $page_id = $this->factory->post->create( array( + $page_id = self::$factory->post->create( array( 'post_type' => 'page', ) ); @@ -269,7 +273,7 @@ NO; * @ticket 31389 */ public function test_get_page_template_slug_non_page() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_type' => 'post', ) ); @@ -284,7 +288,7 @@ NO; * @ticket 33974 */ public function test_wp_page_menu_wp_nav_menu_fallback() { - $pages = $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) ); + $pages = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); // No menus + wp_nav_menu() falls back to wp_page_menu(). $menu = wp_nav_menu( array( 'echo' => false ) ); diff --git a/tests/phpunit/tests/post/wpUniquePostSlug.php b/tests/phpunit/tests/post/wpUniquePostSlug.php index 2aaf1ba1d2..2f7f013683 100644 --- a/tests/phpunit/tests/post/wpUniquePostSlug.php +++ b/tests/phpunit/tests/post/wpUniquePostSlug.php @@ -8,7 +8,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { * @ticket 21013 */ public function test_non_latin_slugs() { - $author_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); $inputs = array( 'Αρνάκι άσπρο και παχύ της μάνας του καμάρι, και άλλα τραγούδια', @@ -49,9 +49,9 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 'post_name' => 'some-slug', 'post_status' => 'publish', ); - $one = $this->factory->post->create( $args ); + $one = self::$factory->post->create( $args ); $args['post_type'] = 'post-type-2'; - $two = $this->factory->post->create( $args ); + $two = self::$factory->post->create( $args ); $this->assertEquals( 'some-slug', get_post( $one )->post_name ); $this->assertEquals( 'some-slug', get_post( $two )->post_name ); @@ -74,9 +74,9 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 'post_name' => 'some-slug', 'post_status' => 'publish', ); - $one = $this->factory->post->create( $args ); + $one = self::$factory->post->create( $args ); $args['post_name'] = 'some-slug-2'; - $two = $this->factory->post->create( $args ); + $two = self::$factory->post->create( $args ); $this->assertEquals( 'some-slug', get_post( $one )->post_name ); $this->assertEquals( 'some-slug-2', get_post( $two )->post_name ); @@ -97,14 +97,14 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 'post_name' => 'some-slug', 'post_status' => 'publish', ); - $one = $this->factory->post->create( $args ); + $one = self::$factory->post->create( $args ); $args = array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', 'post_name' => 'image' ); - $attachment = $this->factory->attachment->create_object( 'image.jpg', $one, $args ); + $attachment = self::$factory->attachment->create_object( 'image.jpg', $one, $args ); $args = array( 'post_type' => 'post-type-1', @@ -112,7 +112,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 'post_status' => 'publish', 'post_parent' => $one ); - $two = $this->factory->post->create( $args ); + $two = self::$factory->post->create( $args ); $this->assertEquals( 'some-slug', get_post( $one )->post_name ); $this->assertEquals( 'image', get_post( $attachment )->post_name ); @@ -128,12 +128,12 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { * @dataProvider whitelist_post_statuses */ public function test_whitelisted_post_statuses_should_not_be_forced_to_be_unique( $status ) { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'post', ) ); @@ -151,12 +151,12 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { } public function test_revisions_should_not_be_forced_to_be_unique() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'post', ) ); @@ -171,7 +171,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() { $this->set_permalink_structure( '/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -186,7 +186,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() { $this->set_permalink_structure( '/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', 'post_status' => 'publish', @@ -202,7 +202,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -217,7 +217,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -232,7 +232,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() { $this->set_permalink_structure( '/%year%/foo/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -247,7 +247,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -262,7 +262,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -277,7 +277,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); @@ -292,7 +292,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'post_type' => 'post', 'post_name' => 'foo', ) ); diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index bb29d18d5e..1bcf175e7c 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -14,8 +14,8 @@ class Tests_Query extends WP_UnitTestCase { * */ function test_nested_loop_reset_postdata() { - $post_id = $this->factory->post->create(); - $nested_post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); + $nested_post_id = self::$factory->post->create(); $first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) ); while ( $first_query->have_posts() ) { $first_query->the_post(); @@ -43,7 +43,7 @@ class Tests_Query extends WP_UnitTestCase { * @ticket 25380 */ function test_pre_posts_per_page() { - $this->factory->post->create_many( 10 ); + self::$factory->post->create_many( 10 ); add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) ); @@ -61,7 +61,7 @@ class Tests_Query extends WP_UnitTestCase { */ function test_tag_queried_object() { $slug = 'tag-slug-26627'; - $this->factory->tag->create( array( 'slug' => $slug ) ); + self::$factory->tag->create( array( 'slug' => $slug ) ); $tag = get_term_by( 'slug', $slug, 'post_tag' ); add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); @@ -94,11 +94,11 @@ class Tests_Query extends WP_UnitTestCase { // Don't override the args provided below. remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $terms[0] ), 'wptests_tax' ); wp_set_object_terms( $posts[1], array( $terms[1] ), 'wptests_tax' ); @@ -130,18 +130,18 @@ class Tests_Query extends WP_UnitTestCase { } public function test_cat_querystring_single_term() { - $c1 = $this->factory->category->create( array( + $c1 = self::$factory->category->create( array( 'name' => 'Test Category 1', 'slug' => 'test1', ) ); - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'name' => 'Test Category 2', 'slug' => 'test2', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $c1, 'category' ); wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); @@ -159,23 +159,23 @@ class Tests_Query extends WP_UnitTestCase { } public function test_category_querystring_multiple_terms_comma_separated() { - $c1 = $this->factory->category->create( array( + $c1 = self::$factory->category->create( array( 'name' => 'Test Category 1', 'slug' => 'test1', ) ); - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'name' => 'Test Category 2', 'slug' => 'test2', ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Test Category 3', 'slug' => 'test3', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, $c1, 'category' ); wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); @@ -197,23 +197,23 @@ class Tests_Query extends WP_UnitTestCase { * @ticket 33532 */ public function test_category_querystring_multiple_terms_formatted_as_array() { - $c1 = $this->factory->category->create( array( + $c1 = self::$factory->category->create( array( 'name' => 'Test Category 1', 'slug' => 'test1', ) ); - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'name' => 'Test Category 2', 'slug' => 'test2', ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Test Category 3', 'slug' => 'test3', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, $c1, 'category' ); wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); @@ -233,18 +233,18 @@ class Tests_Query extends WP_UnitTestCase { public function test_tag_querystring_single_term() { - $t1 = $this->factory->tag->create_and_get( array( + $t1 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 1', 'slug' => 'test1', ) ); - $t2 = $this->factory->tag->create_and_get( array( + $t2 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 2', 'slug' => 'test2', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $t1->slug, 'post_tag' ); wp_set_object_terms( $p2, array( $t1->slug, $t2->slug ), 'post_tag' ); @@ -262,23 +262,23 @@ class Tests_Query extends WP_UnitTestCase { } public function test_tag_querystring_multiple_terms_comma_separated() { - $c1 = $this->factory->tag->create_and_get( array( + $c1 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 1', 'slug' => 'test1', ) ); - $c2 = $this->factory->tag->create_and_get( array( + $c2 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 2', 'slug' => 'test2', ) ); - $c3 = $this->factory->tag->create_and_get( array( + $c3 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 3', 'slug' => 'test3', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, $c1->slug, 'post_tag' ); wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' ); @@ -300,23 +300,23 @@ class Tests_Query extends WP_UnitTestCase { * @ticket 33532 */ public function test_tag_querystring_multiple_terms_formatted_as_array() { - $c1 = $this->factory->tag->create_and_get( array( + $c1 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 1', 'slug' => 'test1', ) ); - $c2 = $this->factory->tag->create_and_get( array( + $c2 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 2', 'slug' => 'test2', ) ); - $c3 = $this->factory->tag->create_and_get( array( + $c3 = self::$factory->tag->create_and_get( array( 'name' => 'Test Tag 3', 'slug' => 'test3', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, $c1->slug, 'post_tag' ); wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' ); @@ -341,9 +341,9 @@ class Tests_Query extends WP_UnitTestCase { wp_insert_term( 'test2', 'test_tax_cat' ); wp_insert_term( 'test3', 'test_tax_cat' ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); @@ -365,10 +365,10 @@ class Tests_Query extends WP_UnitTestCase { wp_insert_term( 'test2', 'test_tax_cat' ); wp_insert_term( 'test3', 'test_tax_cat' ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); @@ -394,10 +394,10 @@ class Tests_Query extends WP_UnitTestCase { wp_insert_term( 'test2', 'test_tax_cat' ); wp_insert_term( 'test3', 'test_tax_cat' ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); @@ -417,7 +417,7 @@ class Tests_Query extends WP_UnitTestCase { * @ticket 31355 */ public function test_pages_dont_404_when_queried_post_id_is_modified() { - $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) ); add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); @@ -438,7 +438,7 @@ class Tests_Query extends WP_UnitTestCase { register_post_type( 'guide', array( 'name' => 'Guide', 'public' => true, 'hierarchical' => true ) ); $wp_rewrite->flush_rules(); - $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) ); add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 5814428b1e..c645a46229 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -45,50 +45,50 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_permalink() { - $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue('is_single', 'is_singular'); } function test_post_comments_feed() { - $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) ); - $this->factory->comment->create_post_comments( $post_id, 2 ); + $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); + self::$factory->comment->create_post_comments( $post_id, 2 ); $this->go_to( get_post_comments_feed_link( $post_id ) ); $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed'); } function test_post_comments_feed_with_no_comments() { - $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); $this->go_to( get_post_comments_feed_link( $post_id ) ); $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed'); } function test_page() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); $this->go_to( get_permalink( $page_id ) ); $this->assertQueryTrue('is_page','is_singular'); } function test_parent_page() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); $this->go_to( get_permalink( $page_id ) ); $this->assertQueryTrue('is_page','is_singular'); } function test_child_page_1() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); $this->go_to( get_permalink( $page_id ) ); $this->assertQueryTrue('is_page','is_singular'); } function test_child_page_2() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); $this->go_to( get_permalink( $page_id ) ); $this->assertQueryTrue('is_page','is_singular'); @@ -97,9 +97,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1' function test_page_trackback() { $page_ids = array(); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); foreach ( $page_ids as $page_id ) { $url = get_permalink( $page_id ); $this->go_to("{$url}trackback/"); @@ -116,11 +116,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { //'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' function test_page_feed() { $page_ids = array(); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); foreach ( $page_ids as $page_id ) { - $this->factory->comment->create_post_comments( $page_id, 2 ); + self::$factory->comment->create_post_comments( $page_id, 2 ); $url = get_permalink( $page_id ); $this->go_to("{$url}feed/"); @@ -135,9 +135,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { function test_page_feed_with_no_comments() { $page_ids = array(); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); foreach ( $page_ids as $page_id ) { $url = get_permalink( $page_id ); $this->go_to("{$url}feed/"); @@ -154,11 +154,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' function test_page_feed_atom() { $page_ids = array(); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); - $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); + $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); foreach ( $page_ids as $page_id ) { - $this->factory->comment->create_post_comments( $page_id, 2 ); + self::$factory->comment->create_post_comments( $page_id, 2 ); $url = get_permalink( $page_id ); $this->go_to("{$url}feed/atom/"); @@ -174,7 +174,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' function test_page_page_2() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); $this->go_to("/about/page/2/"); // make sure the correct wp_query flags are set @@ -187,7 +187,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' function test_page_page_2_no_slash() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); $this->go_to("/about/page2/"); // make sure the correct wp_query flags are set @@ -201,7 +201,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // FIXME: what is this for? // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' function test_pagination_of_posts_page() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 Page 2' ) ); update_option( 'show_on_front', 'page' ); update_option( 'page_for_posts', $page_id ); @@ -223,7 +223,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', function test_main_feed_2() { - $this->factory->post->create(); // @test_404 + self::$factory->post->create(); // @test_404 $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom'); // long version @@ -241,7 +241,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_main_feed() { - $this->factory->post->create(); // @test_404 + self::$factory->post->create(); // @test_404 $types = array('rss2', 'rss', 'atom'); foreach ($types as $type) { $this->go_to(get_feed_link($type)); @@ -252,7 +252,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', function test_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 5 ); + self::$factory->post->create_many( 5 ); for ( $i = 2; $i <= 3; $i++ ) { $this->go_to("/page/{$i}/"); $this->assertQueryTrue('is_home', 'is_paged'); @@ -262,8 +262,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', function test_main_comments_feed() { - $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) ); - $this->factory->comment->create_post_comments( $post_id, 2 ); + $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); + self::$factory->comment->create_post_comments( $post_id, 2 ); // check the url as generated by get_post_comments_feed_link() $this->go_to( get_post_comments_feed_link( $post_id ) ); @@ -306,7 +306,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', function test_search_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 3, array( 'post_title' => 'test' ) ); + self::$factory->post->create_many( 3, array( 'post_title' => 'test' ) ); $this->go_to('/search/test/page/2/'); $this->assertQueryTrue('is_search', 'is_paged'); } @@ -328,7 +328,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', function test_category_feed() { - $this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); + self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -347,14 +347,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', function test_category_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 3 ); + self::$factory->post->create_many( 3 ); $this->go_to('/category/uncategorized/page/2/'); $this->assertQueryTrue('is_archive', 'is_category', 'is_paged'); } // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', function test_category() { - $this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); + self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); $this->go_to('/category/cat-a/'); $this->assertQueryTrue('is_archive', 'is_category'); } @@ -362,7 +362,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', function test_tag_feed() { - $this->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) ); + self::$factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -381,16 +381,16 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', function test_tag_paged() { update_option( 'posts_per_page', 2 ); - $post_ids = $this->factory->post->create_many( 3 ); + $post_ids = self::$factory->post->create_many( 3 ); foreach ( $post_ids as $post_id ) - $this->factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); + self::$factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); $this->go_to('/tag/tag-a/page/2/'); $this->assertQueryTrue('is_archive', 'is_tag', 'is_paged'); } // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', function test_tag() { - $term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); + $term_id = self::$factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); $this->go_to('/tag/tag-a/'); $this->assertQueryTrue('is_archive', 'is_tag'); @@ -409,7 +409,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', function test_author_feed() { - $this->factory->user->create( array( 'user_login' => 'user-a' ) ); + self::$factory->user->create( array( 'user_login' => 'user-a' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -428,22 +428,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', function test_author_paged() { update_option( 'posts_per_page', 2 ); - $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) ); - $this->factory->post->create_many( 3, array( 'post_author' => $user_id ) ); + $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); + self::$factory->post->create_many( 3, array( 'post_author' => $user_id ) ); $this->go_to('/author/user-a/page/2/'); $this->assertQueryTrue('is_archive', 'is_author', 'is_paged'); } // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', function test_author() { - $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) ); - $this->factory->post->create( array( 'post_author' => $user_id ) ); + $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); + self::$factory->post->create( array( 'post_author' => $user_id ) ); $this->go_to('/author/user-a/'); $this->assertQueryTrue('is_archive', 'is_author'); } function test_author_with_no_posts() { - $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) ); + $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); $this->go_to('/author/user-a/'); $this->assertQueryTrue('is_archive', 'is_author'); } @@ -451,7 +451,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', function test_ymd_feed() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -470,14 +470,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', function test_ymd_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/09/04/page/2/'); $this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged'); } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', function test_ymd() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/09/04/'); $this->assertQueryTrue('is_archive', 'is_day', 'is_date'); } @@ -485,7 +485,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', function test_ym_feed() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -504,14 +504,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', function test_ym_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/09/page/2/'); $this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged'); } // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', function test_ym() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/09/'); $this->assertQueryTrue('is_archive', 'is_date', 'is_month'); } @@ -519,7 +519,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', function test_y_feed() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { @@ -538,21 +538,21 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', function test_y_paged() { update_option( 'posts_per_page', 2 ); - $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/page/2/'); $this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged'); } // '([0-9]{4})/?$' => 'index.php?year=$matches[1]', function test_y() { - $this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); + self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to('/2007/'); $this->assertQueryTrue('is_archive', 'is_date', 'is_year'); } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', function test_post_trackback() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $this->go_to("{$permalink}trackback/"); $this->assertQueryTrue('is_single', 'is_singular', 'is_trackback'); @@ -561,7 +561,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', function test_post_comment_feed() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); @@ -580,7 +580,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', function test_post_paged_short() { - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00', 'post_title' => 'a-post-with-multiple-pages', 'post_content' => 'Page 1 Page 2' @@ -593,7 +593,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', function test_post_attachment() { - $post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); $permalink = get_attachment_link( $post_id ); $this->go_to($permalink); $this->assertQueryTrue('is_single', 'is_attachment', 'is_singular'); @@ -629,8 +629,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { 'public' => true ) ); - $tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) ); - $post_id = $this->factory->post->create( array( 'post_type' => $cpt_name ) ); + $tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => $cpt_name ) ); wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); $this->go_to( '/ptawtq/' ); @@ -663,7 +663,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { 'has_archive' => true, 'public' => true ) ); - $this->factory->post->create( array( 'post_type' => $cpt_name ) ); + self::$factory->post->create( array( 'post_type' => $cpt_name ) ); $this->go_to( "/$cpt_name/" ); $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); @@ -683,7 +683,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_is_single() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $this->go_to( "/?p=$post_id" ); $post = get_queried_object(); @@ -714,12 +714,12 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { ) ); // Create parent and child posts - $parent_id = $this->factory->post->create( array( + $parent_id = self::$factory->post->create( array( 'post_type' => $post_type, 'post_name' => 'foo' ) ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_type' => $post_type, 'post_name' => 'bar', 'post_parent' => $parent_id @@ -750,10 +750,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_with_another_post_id() { - $p1 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); $p2_name = $p1 . '-post'; - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'slug' => $p2_name, ) ); @@ -768,7 +768,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_is_page() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" ); $post = get_queried_object(); @@ -788,11 +788,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 16802 */ function test_is_page_with_parent() { - $parent_id = $this->factory->post->create( array( + $parent_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'foo', ) ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => 'bar', 'post_parent' => $parent_id, @@ -818,7 +818,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_is_attachment() { - $post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); $this->go_to( "/?attachment_id=$post_id" ); $post = get_queried_object(); @@ -839,10 +839,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_attachment_with_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() { - $p1 = $this->factory->post->create( array( 'post_type' => 'attachment' ) ); + $p1 = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); $p2_name = $p1 . '-attachment'; - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'attachment', 'post_name' => $p2_name, ) ); @@ -861,10 +861,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() { - $u1 = $this->factory->user->create(); + $u1 = self::$factory->user->create(); $u2_name = $u1 . '_user'; - $u2 = $this->factory->user->create( array( + $u2 = self::$factory->user->create( array( 'user_nicename' => $u2_name, ) ); @@ -882,10 +882,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_category_with_slug_that_begins_with_a_number_that_clashes_with_another_category_id() { - $c1 = $this->factory->category->create(); + $c1 = self::$factory->category->create(); $c2_name = $c1 . '-category'; - $c2 = $this->factory->category->create( array( + $c2 = self::$factory->category->create( array( 'slug' => $c2_name, ) ); @@ -903,10 +903,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_tag_with_slug_that_begins_with_a_number_that_clashes_with_another_tag_id() { - $t1 = $this->factory->tag->create(); + $t1 = self::$factory->tag->create(); $t2_name = $t1 . '-tag'; - $t2 = $this->factory->tag->create( array( + $t2 = self::$factory->tag->create( array( 'slug' => $t2_name, ) ); @@ -924,7 +924,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_page_with_page_id_zero_and_random_page_slug() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" ); // override post ID to 0 temporarily for testing @@ -946,10 +946,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 24674 */ public function test_is_page_with_page_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() { - $p1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $p1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); $p2_name = $p1 . '-page'; - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_name' => $p2_name, ) ); @@ -965,7 +965,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } function test_is_page_template() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); update_post_meta($post_id, '_wp_page_template', 'example.php'); $this->go_to( "/?page_id=$post_id" ); $this->assertTrue( is_page_template( 'example.php' ) ); @@ -975,7 +975,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 31271 */ function test_is_page_template_default() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" ); $this->assertTrue( is_page_template( 'default' ) ); $this->assertTrue( is_page_template( array( 'random', 'default' ) ) ); @@ -985,7 +985,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { * @ticket 31271 */ function test_is_page_template_array() { - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); update_post_meta($post_id, '_wp_page_template', 'example.php'); $this->go_to( "/?page_id=$post_id" ); $this->assertFalse( is_page_template( array( 'test.php' ) ) ); diff --git a/tests/phpunit/tests/query/dateQuery.php b/tests/phpunit/tests/query/dateQuery.php index f7b4263743..0e79426dba 100644 --- a/tests/phpunit/tests/query/dateQuery.php +++ b/tests/phpunit/tests/query/dateQuery.php @@ -33,10 +33,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_before_array() { - $p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); - $p4 = $this->factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); + $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -57,8 +57,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * their minimum values when being used with "before". */ public function test_date_query_before_array_test_defaulting() { - $p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -74,10 +74,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_before_string() { - $p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); - $p4 = $this->factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); + $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -91,9 +91,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_after_array() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -115,8 +115,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * their maximum values when being used with "after". */ public function test_date_query_after_array_test_defaulting() { - $p1 = $this->factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -132,9 +132,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_after_string() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -148,9 +148,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_after_string_inclusive() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -168,11 +168,11 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 26653 */ public function test_date_query_inclusive_between_dates() { - $p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) ); - $p4 = $this->factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) ); - $p5 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) ); + $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) ); + $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -195,10 +195,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Y() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2007-05-07 13:00:00', ) ); @@ -228,10 +228,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Y_inclusive() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2007-05-07 13:00:00', ) ); @@ -263,10 +263,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Ym() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-04-07 13:00:00', ) ); @@ -296,10 +296,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Ym_inclusive() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-04-07 13:00:00', ) ); @@ -331,10 +331,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Ymd() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-05 13:00:00', ) ); @@ -364,10 +364,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_Ymd_inclusive() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 13:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-05 13:00:00', ) ); @@ -399,10 +399,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_YmdHi() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:04:00', ) ); @@ -432,10 +432,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_YmdHi_inclusive() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:04:00', ) ); @@ -467,10 +467,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_YmdHis() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:15', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:14', ) ); @@ -500,10 +500,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_YmdHis_inclusive() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:04:15', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:04:14', ) ); @@ -535,10 +535,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29908 */ public function test_beforeafter_with_date_string_non_parseable() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:15', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2008-05-06 14:05:14', ) ); @@ -564,8 +564,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_year() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( array( @@ -578,8 +578,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_month() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( array( @@ -592,8 +592,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_week() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( array( @@ -606,8 +606,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_day() { - $p1 = $this->factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -621,8 +621,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_dayofweek() { - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -639,8 +639,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 28063 */ public function test_date_query_dayofweek_iso() { - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -654,8 +654,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_hour() { - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -673,8 +673,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { */ public function test_date_query_hour_should_not_ignore_0() { return; - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) ); $posts = $this->_get_query_result( array( 'year' => 2014, @@ -688,8 +688,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_minute() { - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -703,8 +703,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_second() { - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -718,11 +718,11 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_between_two_times() { - $p1 = $this->factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) ); - $p4 = $this->factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) ); - $p5 = $this->factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) ); + $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) ); + $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -743,9 +743,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_relation_or() { - $p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -763,10 +763,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { } public function test_date_query_compare_greater_than_or_equal_to() { - $p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) ); - $p4 = $this->factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) ); + $p4 = self::$factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -784,9 +784,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { public function test_date_params_monthnum_m_duplicate() { global $wpdb; - $p1 = $this->factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -804,9 +804,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { public function test_date_params_week_w_duplicate() { global $wpdb; - $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( @@ -825,10 +825,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 25775 */ public function test_date_query_with_taxonomy_join() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2013-04-27 01:01:01', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2013-03-21 01:01:01', ) ); @@ -857,10 +857,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29822 */ public function test_date_query_one_nested_query() { - $p1 = $this->factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) ); - $p2 = $this->factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) ); - $p3 = $this->factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) ); - $p4 = $this->factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) ); + $p1 = self::$factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) ); + $p2 = self::$factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) ); + $p3 = self::$factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) ); + $p4 = self::$factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) ); $posts = $this->_get_query_result( array( 'date_query' => array( 'relation' => 'OR', @@ -886,22 +886,22 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29822 */ public function test_date_query_one_nested_query_multiple_columns_relation_and() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2012-03-05 15:30:55', ) ); $this->update_post_modified( $p1, '2014-11-03 14:43:00' ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2012-05-05 15:30:55', ) ); $this->update_post_modified( $p2, '2014-10-03 14:43:00' ); - $p3 = $this->factory->post->create( array( + $p3 = self::$factory->post->create( array( 'post_date' => '2013-05-05 15:30:55', ) ); $this->update_post_modified( $p3, '2014-10-03 14:43:00' ); - $p4 = $this->factory->post->create( array( + $p4 = self::$factory->post->create( array( 'post_date' => '2012-02-05 15:30:55', ) ); $this->update_post_modified( $p4, '2012-12-03 14:43:00' ); @@ -937,27 +937,27 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { * @ticket 29822 */ public function test_date_query_nested_query_multiple_columns_mixed_relations() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2012-03-05 15:30:55', ) ); $this->update_post_modified( $p1, '2014-11-03 14:43:00' ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2012-05-05 15:30:55', ) ); $this->update_post_modified( $p2, '2014-10-03 14:43:00' ); - $p3 = $this->factory->post->create( array( + $p3 = self::$factory->post->create( array( 'post_date' => '2013-05-05 15:30:55', ) ); $this->update_post_modified( $p3, '2014-10-03 14:43:00' ); - $p4 = $this->factory->post->create( array( + $p4 = self::$factory->post->create( array( 'post_date' => '2012-02-05 15:30:55', ) ); $this->update_post_modified( $p4, '2012-12-03 14:43:00' ); - $p5 = $this->factory->post->create( array( + $p5 = self::$factory->post->create( array( 'post_date' => '2014-02-05 15:30:55', ) ); $this->update_post_modified( $p5, '2013-12-03 14:43:00' ); diff --git a/tests/phpunit/tests/query/isTerm.php b/tests/phpunit/tests/query/isTerm.php index 99055fa351..6dcf4c94cd 100644 --- a/tests/phpunit/tests/query/isTerm.php +++ b/tests/phpunit/tests/query/isTerm.php @@ -37,11 +37,11 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { flush_rewrite_rules(); - $this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) ); - $this->cat_id = $this->factory->category->create( array( 'slug' => 'cat-slug' ) ); - $this->tax_id = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) ); - $this->tax_id2 = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) ); - $this->post_id = $this->factory->post->create(); + $this->tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) ); + $this->cat_id = self::$factory->category->create( array( 'slug' => 'cat-slug' ) ); + $this->tax_id = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) ); + $this->tax_id2 = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) ); + $this->post_id = self::$factory->post->create(); wp_set_object_terms( $this->post_id, $this->cat_id, 'category' ); wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' ); @@ -245,7 +245,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); register_taxonomy( 'testtax2', 'post' ); - $testtax2_term_id = $this->factory->term->create( array( + $testtax2_term_id = self::$factory->term->create( array( 'taxonomy' => 'testtax2', 'slug' => 'testtax2-slug', ) ); diff --git a/tests/phpunit/tests/query/metaQuery.php b/tests/phpunit/tests/query/metaQuery.php index c550e00ba0..1bc5aab09d 100644 --- a/tests/phpunit/tests/query/metaQuery.php +++ b/tests/phpunit/tests/query/metaQuery.php @@ -6,9 +6,9 @@ */ class Tests_Query_MetaQuery extends WP_UnitTestCase { public function test_meta_query_no_key() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'oof', 'bar' ); @@ -30,9 +30,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_no_value() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'oof', 'bar' ); @@ -54,8 +54,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_default() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); @@ -76,8 +76,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_equals() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); @@ -99,9 +99,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_not_equals() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'foo', 'baz' ); @@ -124,9 +124,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_arithmetic_comparisons() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', '1' ); add_post_meta( $p2, 'foo', '2' ); @@ -202,8 +202,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_like() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); @@ -225,9 +225,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_not_like() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'foo', 'rab' ); @@ -250,9 +250,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_between_not_between() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', '1' ); add_post_meta( $p2, 'foo', '10' ); @@ -294,8 +294,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_regexp_rlike() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'foo', 'baz' ); @@ -335,8 +335,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_single_query_compare_not_regexp() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'foo', 'baz' ); @@ -359,9 +359,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_relation_default() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'foo value 1' ); add_post_meta( $p1, 'bar', 'bar value 1' ); @@ -389,18 +389,18 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_relation_or() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'foo', rand_str() ); add_post_meta( $post_id, 'foo', rand_str() ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'bar', 'val2' ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'baz', rand_str() ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'froo', rand_str() ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'tango', 'val2' ); - $post_id6 = $this->factory->post->create(); + $post_id6 = self::$factory->post->create(); add_post_meta( $post_id6, 'bar', 'val1' ); $query = new WP_Query( array( @@ -430,22 +430,22 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_query_relation_and() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'foo', rand_str() ); add_post_meta( $post_id, 'foo', rand_str() ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'bar', 'val2' ); add_post_meta( $post_id2, 'foo', rand_str() ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'baz', rand_str() ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'froo', rand_str() ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'tango', 'val2' ); - $post_id6 = $this->factory->post->create(); + $post_id6 = self::$factory->post->create(); add_post_meta( $post_id6, 'bar', 'val1' ); add_post_meta( $post_id6, 'foo', rand_str() ); - $post_id7 = $this->factory->post->create(); + $post_id7 = self::$factory->post->create(); add_post_meta( $post_id7, 'foo', rand_str() ); add_post_meta( $post_id7, 'froo', rand_str() ); add_post_meta( $post_id7, 'baz', rand_str() ); @@ -499,7 +499,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 30681 */ public function test_meta_query_compare_exists() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); add_post_meta( $posts[0], 'foo', 'bar' ); add_post_meta( $posts[2], 'foo', 'baz' ); @@ -520,7 +520,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 30681 */ public function test_meta_query_compare_exists_with_value_should_convert_to_equals() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); add_post_meta( $posts[0], 'foo', 'bar' ); add_post_meta( $posts[2], 'foo', 'baz' ); @@ -542,7 +542,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 30681 */ public function test_meta_query_compare_not_exists_should_ignore_value() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); add_post_meta( $posts[0], 'foo', 'bar' ); add_post_meta( $posts[2], 'foo', 'baz' ); @@ -564,15 +564,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 18158 */ public function test_meta_query_compare_not_exists() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'foo', rand_str() ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'bar', rand_str() ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'bar', rand_str() ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'baz', rand_str() ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'foo', rand_str() ); $query = new WP_Query( array( @@ -636,7 +636,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 29062 */ public function test_meta_query_compare_not_exists_with_another_condition_relation_or() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); update_post_meta( $posts[0], 'color', 'orange' ); update_post_meta( $posts[1], 'color', 'blue' ); update_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -672,7 +672,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_or_compare_equals() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -705,7 +705,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_or_compare_equals_different_keys() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -738,7 +738,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_or_compare_equals_and_in() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -771,7 +771,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_or_compare_equals_and_like() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -804,7 +804,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_or_compare_equals_and_between() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'number_of_colors', '2' ); add_post_meta( $posts[1], 'number_of_colors', '5' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -838,7 +838,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_in_same_keys() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -873,7 +873,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_in_different_keys() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -908,7 +908,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_not_equals() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -942,7 +942,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_not_equals_different_keys() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); // !shallot, but orange. add_post_meta( $posts[0], 'color', 'orange' ); @@ -983,7 +983,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_not_equals_not_in() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -1017,7 +1017,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 24093 */ public function test_meta_query_relation_and_compare_not_equals_and_not_like() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); add_post_meta( $posts[0], 'color', 'orange' ); add_post_meta( $posts[1], 'color', 'blue' ); add_post_meta( $posts[1], 'vegetable', 'onion' ); @@ -1051,10 +1051,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 23033 */ public function test_meta_query_decimal_results() { - $post_1 = $this->factory->post->create(); - $post_2 = $this->factory->post->create(); - $post_3 = $this->factory->post->create(); - $post_4 = $this->factory->post->create(); + $post_1 = self::$factory->post->create(); + $post_2 = self::$factory->post->create(); + $post_3 = self::$factory->post->create(); + $post_4 = self::$factory->post->create(); update_post_meta( $post_1, 'decimal_value', '-0.3' ); update_post_meta( $post_2, 'decimal_value', '0.23409844' ); @@ -1226,7 +1226,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 29604 */ public function test_meta_query_with_orderby_meta_value_relation_or() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); update_post_meta( $posts[0], 'foo', 5 ); update_post_meta( $posts[1], 'foo', 6 ); update_post_meta( $posts[2], 'foo', 4 ); @@ -1265,7 +1265,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 29604 */ public function test_meta_query_with_orderby_meta_value_relation_and() { - $posts = $this->factory->post->create_many( 4 ); + $posts = self::$factory->post->create_many( 4 ); update_post_meta( $posts[0], 'foo', 5 ); update_post_meta( $posts[1], 'foo', 6 ); update_post_meta( $posts[2], 'foo', 4 ); @@ -1308,9 +1308,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 29642 */ public function test_meta_query_nested() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p2, 'foo2', 'bar' ); @@ -1349,9 +1349,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 29642 */ public function test_meta_query_nested_two_levels_deep() { - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); add_post_meta( $p1, 'foo', 'bar' ); add_post_meta( $p3, 'foo2', 'bar' ); @@ -1394,15 +1394,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { } public function test_meta_between_not_between() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'time', 500 ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'time', 1001 ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'time', 0 ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'time', 1 ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'time', 1000 ); $args = array( @@ -1443,15 +1443,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { */ public function test_meta_default_compare() { // compare should default to IN when meta_value is an array - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'foo', 'bar' ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'bar', 'baz' ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'foo', 'baz' ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'baz', 'bar' ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'foo', rand_str() ); $posts = get_posts( array( @@ -1482,12 +1482,12 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 17264 */ public function test_duplicate_posts_when_no_key() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'city', 'Lorem' ); add_post_meta( $post_id, 'address', '123 Lorem St.' ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'city', 'Lorem' ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'city', 'Loren' ); $args = array( @@ -1513,19 +1513,19 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 15292 */ public function test_empty_meta_value() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); add_post_meta( $post_id, 'foo', '0' ); add_post_meta( $post_id, 'bar', 0 ); - $post_id2 = $this->factory->post->create(); + $post_id2 = self::$factory->post->create(); add_post_meta( $post_id2, 'foo', 1 ); - $post_id3 = $this->factory->post->create(); + $post_id3 = self::$factory->post->create(); add_post_meta( $post_id3, 'baz', 0 ); - $post_id4 = $this->factory->post->create(); + $post_id4 = self::$factory->post->create(); add_post_meta( $post_id4, 'baz', 0 ); - $post_id5 = $this->factory->post->create(); + $post_id5 = self::$factory->post->create(); add_post_meta( $post_id5, 'baz', 0 ); add_post_meta( $post_id5, 'bar', '0' ); - $post_id6 = $this->factory->post->create(); + $post_id6 = self::$factory->post->create(); add_post_meta( $post_id6, 'baz', 0 ); $q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) ); @@ -1577,7 +1577,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 31045 */ public function test_orderby_clause_key() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); add_post_meta( $posts[0], 'foo', 'aaa' ); add_post_meta( $posts[1], 'foo', 'zzz' ); add_post_meta( $posts[2], 'foo', 'jjj' ); @@ -1601,13 +1601,13 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 31045 */ public function test_orderby_clause_key_as_secondary_sort() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-28 03:00:00', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-28 05:00:00', ) ); - $p3 = $this->factory->post->create( array( + $p3 = self::$factory->post->create( array( 'post_date' => '2015-01-28 03:00:00', ) ); @@ -1636,7 +1636,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { * @ticket 31045 */ public function test_orderby_more_than_one_clause_key() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); add_post_meta( $posts[0], 'foo', 'jjj' ); add_post_meta( $posts[1], 'foo', 'zzz' ); diff --git a/tests/phpunit/tests/query/postStatus.php b/tests/phpunit/tests/query/postStatus.php index 987a88d6d4..764cc76b74 100644 --- a/tests/phpunit/tests/query/postStatus.php +++ b/tests/phpunit/tests/query/postStatus.php @@ -211,7 +211,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_status_should_not_be_shown_to_logged_out_users() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps' ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps' ) ); $q = new WP_Query( array( 'p' => $p, @@ -223,7 +223,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); wp_set_current_user( self::$author_user_id ); @@ -237,7 +237,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_and_protected_status_should_be_shown_for_user_who_can_edit_others_posts() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); wp_set_current_user( self::$editor_user_id ); @@ -251,7 +251,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_and_private_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); wp_set_current_user( self::$author_user_id ); @@ -265,7 +265,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_and_private_status_should_be_shown_for_user_who_can_edit_others_posts() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); wp_set_current_user( self::$editor_user_id ); @@ -279,7 +279,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_any_user() { register_post_type( 'foo_pt' ); register_post_status( 'foo_ps', array( 'public' => false ) ); - $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); + $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); wp_set_current_user( self::$editor_user_id ); @@ -294,8 +294,8 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { * @ticket 29167 */ public function test_specific_post_should_be_returned_if_trash_is_one_of_the_requested_post_statuses() { - $p1 = $this->factory->post->create( array( 'post_status' => 'trash' ) ); - $p2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $p1 = self::$factory->post->create( array( 'post_status' => 'trash' ) ); + $p2 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); $q = new WP_Query( array( 'p' => $p1, diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 380b2aabd2..9cd81fc389 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -456,17 +456,17 @@ class Tests_Query_Results extends WP_UnitTestCase { * @ticket 16854 */ function test_query_author_vars() { - $author_1 = $this->factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_1 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_1 = self::$factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) ); + $post_1 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_2 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_2 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_2 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); + $post_2 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_3 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_3 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_3 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); + $post_3 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_4 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_4 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_4 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); + $post_4 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); $posts = $this->q->query( array( 'author' => '', @@ -623,9 +623,9 @@ class Tests_Query_Results extends WP_UnitTestCase { * @ticket 20308 */ function test_post_password() { - $one = (string) $this->factory->post->create( array( 'post_password' => '' ) ); - $two = (string) $this->factory->post->create( array( 'post_password' => 'burrito' ) ); - $three = (string) $this->factory->post->create( array( 'post_password' => 'burrito' ) ); + $one = (string) self::$factory->post->create( array( 'post_password' => '' ) ); + $two = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) ); + $three = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) ); $args = array( 'post__in' => array( $one, $two, $three ), 'fields' => 'ids' ); @@ -665,9 +665,9 @@ class Tests_Query_Results extends WP_UnitTestCase { function test_duplicate_slug_in_hierarchical_post_type() { register_post_type( 'handbook', array( 'hierarchical' => true ) ); - $post_1 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) ); - $post_2 = $this->factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); - $post_3 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) ); + $post_1 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) ); + $post_2 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); + $post_3 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) ); $result = $this->q->query( array( 'handbook' => 'getting-started', 'post_type' => 'handbook' ) ); $this->assertCount( 1, $result ); @@ -679,8 +679,8 @@ class Tests_Query_Results extends WP_UnitTestCase { function test_child_post_in_hierarchical_post_type_with_default_permalinks() { register_post_type( 'handbook', array( 'hierarchical' => true ) ); - $post_1 = $this->factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); - $post_2 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) ); + $post_1 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); + $post_2 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) ); $this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) ); @@ -690,7 +690,7 @@ class Tests_Query_Results extends WP_UnitTestCase { function test_title() { $title = 'Tacos are Cool'; - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => $title, 'post_type' => 'post', 'post_status' => 'publish' diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index b81bef3ee1..37bd21a58b 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -31,8 +31,8 @@ class Tests_Query_Search extends WP_UnitTestCase { function test_search_order_title_relevance() { foreach ( range( 1, 7 ) as $i ) - $this->factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) ); - $post_id = $this->factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) ); + self::$factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) ); + $post_id = self::$factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) ); $posts = $this->get_search_results( 'About' ); $this->assertEquals( $post_id, reset( $posts )->ID ); @@ -63,11 +63,11 @@ class Tests_Query_Search extends WP_UnitTestCase { * @ticket 33988 */ public function test_s_should_exclude_term_prefixed_with_dash() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has foo but also bar', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has only foo', ) ); @@ -84,11 +84,11 @@ class Tests_Query_Search extends WP_UnitTestCase { * @ticket 33988 */ public function test_s_should_exclude_first_term_if_prefixed_with_dash() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has foo but also bar', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has only bar', ) ); @@ -105,15 +105,15 @@ class Tests_Query_Search extends WP_UnitTestCase { * @ticket 33988 */ public function test_s_should_not_exclude_for_dashes_in_the_middle_of_words() { - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has foo but also bar', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has only bar', ) ); - $p3 = $this->factory->post->create( array( + $p3 = self::$factory->post->create( array( 'post_status' => 'publish', 'post_content' => 'This post has only foo-bar', ) ); diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index c242a4e480..5381a97a03 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -39,7 +39,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_id() { - $p = $this->factory->post->create_and_get(); + $p = self::$factory->post->create_and_get(); setup_postdata( $p ); $this->assertNotEmpty( $p->ID ); @@ -50,7 +50,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 30970 */ public function test_setup_by_id() { - $p = $this->factory->post->create_and_get(); + $p = self::$factory->post->create_and_get(); setup_postdata( $p->ID ); $this->assertSame( $p->ID, $GLOBALS['id'] ); @@ -72,7 +72,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 30970 */ public function test_setup_by_postish_object() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); $post = new stdClass(); $post->ID = $p; @@ -82,8 +82,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_authordata() { - $u = $this->factory->user->create_and_get(); - $p = $this->factory->post->create_and_get( array( + $u = self::$factory->user->create_and_get(); + $p = self::$factory->post->create_and_get( array( 'post_author' => $u->ID, ) ); setup_postdata( $p ); @@ -93,7 +93,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_currentday() { - $p = $this->factory->post->create_and_get( array( + $p = self::$factory->post->create_and_get( array( 'post_date' => '1980-09-09 06:30:00', ) ); setup_postdata( $p ); @@ -102,7 +102,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_currentmonth() { - $p = $this->factory->post->create_and_get( array( + $p = self::$factory->post->create_and_get( array( 'post_date' => '1980-09-09 06:30:00', ) ); setup_postdata( $p ); @@ -111,14 +111,14 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_secondary_query_post_vars() { - $users = $this->factory->user->create_many( 2 ); + $users = self::$factory->user->create_many( 2 ); - $post1 = $this->factory->post->create_and_get( array( + $post1 = self::$factory->post->create_and_get( array( 'post_author' => $users[0], 'post_date' => '2012-02-02 02:00:00', ) ); - $post2 = $this->factory->post->create_and_get( array( + $post2 = self::$factory->post->create_and_get( array( 'post_author' => $users[1], 'post_date' => '2013-03-03 03:00:00', ) ); @@ -157,7 +157,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_single_page() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_content' => 'Page 0', ) ); setup_postdata( $post ); @@ -168,7 +168,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_multi_page() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_content' => 'Page 0Page 1Page 2Page 3', ) ); setup_postdata( $post ); @@ -182,7 +182,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 16746 */ public function test_nextpage_at_start_of_content() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_content' => 'Page 1Page 2Page 3', ) ); setup_postdata( $post ); @@ -193,7 +193,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_trim_nextpage_linebreaks() { - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'post_content' => "Page 0\n\nPage 1\nhas a line break\nPage 2\n\nPage 3", ) ); setup_postdata( $post ); @@ -205,10 +205,10 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 25349 */ public function test_secondary_query_nextpage() { - $post1 = $this->factory->post->create( array( + $post1 = self::$factory->post->create( array( 'post_content' => 'Post 1 Page 1Post 1 Page 2', ) ); - $post2 = $this->factory->post->create( array( + $post2 = self::$factory->post->create( array( 'post_content' => 'Post 2 Page 1Post 2 Page 2', ) ); @@ -237,7 +237,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_page_from_wp_query() { - $page = $this->factory->post->create_and_get( array( + $page = self::$factory->post->create_and_get( array( 'post_type' => 'page', ) ); @@ -250,7 +250,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { } public function test_page_when_on_page() { - $page = $this->factory->post->create_and_get( array( + $page = self::$factory->post->create_and_get( array( 'post_type' => 'page', ) ); $this->go_to( get_permalink( $page ) ); @@ -263,7 +263,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 20904 */ public function test_secondary_query_page() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $this->go_to( '/?page=3' ); setup_postdata( $post ); @@ -271,7 +271,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->assertSame( 3, $GLOBALS['page'] ); // Secondary loop. - $posts = $this->factory->post->create_many( 5 ); + $posts = self::$factory->post->create_many( 5 ); $q = new WP_Query( array( 'page' => 4, 'posts_per_page' => 1, @@ -294,7 +294,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 20904 */ public function test_more_when_on_setup_post() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $this->go_to( get_permalink( $post ) ); setup_postdata( $post ); @@ -307,8 +307,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * $more should not be true when the set-up post is not the same as the current post. */ public function test_more_when_on_single() { - $post1 = $this->factory->post->create_and_get(); - $post2 = $this->factory->post->create_and_get(); + $post1 = self::$factory->post->create_and_get(); + $post2 = self::$factory->post->create_and_get(); $this->go_to( get_permalink( $post1 ) ); setup_postdata( $post2 ); @@ -321,8 +321,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * $more should not be true when the set-up post is not the same as the current page. */ public function test_more_when_on_page() { - $post = $this->factory->post->create_and_get(); - $page = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get(); + $page = self::$factory->post->create_and_get( array( 'post_type' => 'page', ) ); $this->go_to( get_permalink( $page ) ); @@ -335,7 +335,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 20904 */ public function test_more_when_on_feed() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $this->go_to( '/?feed=rss' ); setup_postdata( $post ); @@ -347,7 +347,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * @ticket 25349 */ public function test_secondary_query_more() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); $this->go_to( get_permalink( $post ) ); setup_postdata( $post ); @@ -379,10 +379,10 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * global $post should use the content of $a_post rather then the global post. */ function test_setup_postdata_loop() { - $post_id = $this->factory->post->create( array( 'post_content' => 'global post' ) ); + $post_id = self::$factory->post->create( array( 'post_content' => 'global post' ) ); $GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id ); - $ids = $this->factory->post->create_many(5); + $ids = self::$factory->post->create_many(5); foreach ( $ids as $id ) { $page = get_post( $id ); if ( $page ) { diff --git a/tests/phpunit/tests/query/taxQuery.php b/tests/phpunit/tests/query/taxQuery.php index 2bf8dbd6d3..cd495b8816 100644 --- a/tests/phpunit/tests/query/taxQuery.php +++ b/tests/phpunit/tests/query/taxQuery.php @@ -6,13 +6,13 @@ */ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_tax_query_single_query_single_term_field_slug() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -33,13 +33,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_field_name() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -65,13 +65,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_field_name_should_work_for_names_with_spaces() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo', 'name' => 'Foo Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_object_terms( $p1, $t, 'wptests_tax' ); @@ -90,13 +90,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_field_term_taxonomy_id() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); $tt_ids = wp_set_post_terms( $p1, $t, 'category' ); @@ -117,13 +117,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_field_term_id() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -144,13 +144,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_operator_in() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -172,13 +172,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_operator_not_in() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -200,13 +200,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_single_term_operator_and() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); wp_set_post_terms( $p1, $t, 'category' ); @@ -228,19 +228,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_multiple_terms_operator_in() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_post_terms( $p1, $t1, 'category' ); wp_set_post_terms( $p2, $t2, 'category' ); @@ -263,19 +263,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_multiple_terms_operator_not_in() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_post_terms( $p1, $t1, 'category' ); wp_set_post_terms( $p2, $t2, 'category' ); @@ -301,19 +301,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { * @ticket 18105 */ public function test_tax_query_single_query_multiple_queries_operator_not_in() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_post_terms( $p1, $t1, 'category' ); wp_set_post_terms( $p2, $t2, 'category' ); @@ -343,19 +343,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_single_query_multiple_terms_operator_and() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $t1, 'category' ); wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); @@ -384,12 +384,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); @@ -416,12 +416,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); @@ -448,12 +448,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); @@ -481,12 +481,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); @@ -506,19 +506,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_multiple_queries_relation_and() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $t1, 'category' ); wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); @@ -546,19 +546,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_multiple_queries_relation_or() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $t1, 'category' ); wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); @@ -586,19 +586,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_multiple_queries_different_taxonomies() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'post_tag', 'slug' => 'foo', 'name' => 'Foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', 'name' => 'Bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, $t1, 'post_tag' ); wp_set_object_terms( $p2, $t2, 'category' ); @@ -632,22 +632,22 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); register_taxonomy( 'bar', 'post' ); - $foo_term_1 = $this->factory->term->create( array( + $foo_term_1 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $foo_term_2 = $this->factory->term->create( array( + $foo_term_2 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $bar_term_1 = $this->factory->term->create( array( + $bar_term_1 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $bar_term_2 = $this->factory->term->create( array( + $bar_term_2 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); @@ -704,22 +704,22 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); register_taxonomy( 'bar', 'post' ); - $foo_term_1 = $this->factory->term->create( array( + $foo_term_1 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $foo_term_2 = $this->factory->term->create( array( + $foo_term_2 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $bar_term_1 = $this->factory->term->create( array( + $bar_term_1 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $bar_term_2 = $this->factory->term->create( array( + $bar_term_2 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); @@ -768,23 +768,23 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); register_taxonomy( 'bar', 'post' ); - $foo_term_1 = $this->factory->term->create( array( + $foo_term_1 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $foo_term_2 = $this->factory->term->create( array( + $foo_term_2 = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $bar_term_1 = $this->factory->term->create( array( + $bar_term_1 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $bar_term_2 = $this->factory->term->create( array( + $bar_term_2 = self::$factory->term->create( array( 'taxonomy' => 'bar', ) ); - $p1 = $this->factory->post->create(); - $p2 = $this->factory->post->create(); - $p3 = $this->factory->post->create(); - $p4 = $this->factory->post->create(); + $p1 = self::$factory->post->create(); + $p2 = self::$factory->post->create(); + $p3 = self::$factory->post->create(); + $p4 = self::$factory->post->create(); wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); @@ -840,7 +840,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_tax_query_relation_or_both_clauses_empty_terms() { // An empty tax query should return an empty array, not all posts. - $this->factory->post->create_many( 2 ); + self::$factory->post->create_many( 2 ); $query = new WP_Query( array( 'fields' => 'ids', @@ -873,7 +873,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_tax_query_relation_or_one_clause_empty_terms() { // An empty tax query should return an empty array, not all posts. - $this->factory->post->create_many( 2 ); + self::$factory->post->create_many( 2 ); $query = new WP_Query( array( 'fields' => 'ids', @@ -901,15 +901,15 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_include_children() { - $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) ); - $cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) ); - $cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) ); - $cat_d = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) ); + $cat_a = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) ); + $cat_b = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) ); + $cat_c = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) ); + $cat_d = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) ); - $post_a = $this->factory->post->create( array( 'post_category' => array( $cat_a ) ) ); - $post_b = $this->factory->post->create( array( 'post_category' => array( $cat_b ) ) ); - $post_c = $this->factory->post->create( array( 'post_category' => array( $cat_c ) ) ); - $post_d = $this->factory->post->create( array( 'post_category' => array( $cat_d ) ) ); + $post_a = self::$factory->post->create( array( 'post_category' => array( $cat_a ) ) ); + $post_b = self::$factory->post->create( array( 'post_category' => array( $cat_b ) ) ); + $post_c = self::$factory->post->create( array( 'post_category' => array( $cat_c ) ) ); + $post_d = self::$factory->post->create( array( 'post_category' => array( $cat_d ) ) ); $posts = get_posts( array( 'fields' => 'ids', @@ -1009,8 +1009,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { $q = new WP_Query(); register_taxonomy_for_object_type( 'post_tag', 'attachment:image' ); - $tag_id = $this->factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) ); - $image_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( + $tag_id = self::$factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) ); + $image_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); @@ -1035,8 +1035,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { } public function test_tax_query_no_taxonomy() { - $cat_id = $this->factory->category->create( array( 'name' => 'alpha' ) ); - $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) ); + $cat_id = self::$factory->category->create( array( 'name' => 'alpha' ) ); + self::$factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) ); $response1 = new WP_Query( array( 'tax_query' => array( @@ -1076,7 +1076,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_term_taxonomy_id_field_no_taxonomy() { $q = new WP_Query(); - $posts = $this->factory->post->create_many( 5 ); + $posts = self::$factory->post->create_many( 5 ); $cats = $tags = array(); @@ -1155,10 +1155,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { */ public function test_populate_taxonomy_query_var_from_tax_query() { register_taxonomy( 'foo', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $c = $this->factory->term->create( array( + $c = self::$factory->term->create( array( 'taxonomy' => 'category', ) ); @@ -1191,7 +1191,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() { register_taxonomy( 'foo', 'post' ); register_taxonomy( 'foo1', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); @@ -1213,7 +1213,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_populate_term_query_var_from_tax_query() { register_taxonomy( 'foo', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'slug' => 'bar', ) ); @@ -1235,7 +1235,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { public function test_populate_term_id_query_var_from_tax_query() { register_taxonomy( 'foo', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'slug' => 'bar', ) ); @@ -1260,10 +1260,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { */ public function test_populate_cat_category_name_query_var_from_tax_query() { register_taxonomy( 'foo', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $c = $this->factory->term->create( array( + $c = self::$factory->term->create( array( 'taxonomy' => 'category', 'slug' => 'bar', ) ); @@ -1301,10 +1301,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { */ public function test_populate_tag_id_query_var_from_tax_query() { register_taxonomy( 'foo', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $tag = $this->factory->term->create( array( + $tag = self::$factory->term->create( array( 'taxonomy' => 'post_tag', 'slug' => 'bar', ) ); diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index b49b5c6eed..bd0abb3205 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -136,7 +136,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { 'permission_callback' => '__return_true', ) ); - $editor = $this->factory->user->create( array( 'role' => 'editor' ) ); + $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); $request = new WP_REST_Request( 'GET', '/test-ns/test', array() ); diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 02b3441a2b..2f60b34349 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -85,19 +85,19 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid() { - $id = $this->factory->post->create(); + $id = self::$factory->post->create(); $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); - $id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); } function test_url_to_postid_set_url_scheme_https_to_http() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $permalink = get_permalink( $post_id ); $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); } @@ -109,11 +109,11 @@ class Tests_Rewrite extends WP_UnitTestCase { $_SERVER['HTTPS'] = 'on'; - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $permalink = get_permalink( $post_id ); $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) ); - $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); $permalink = get_permalink( $post_id ); $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) ); @@ -128,7 +128,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $post_type = rand_str( 12 ); register_post_type( $post_type, array( 'public' => true ) ); - $id = $this->factory->post->create( array( 'post_type' => $post_type ) ); + $id = self::$factory->post->create( array( 'post_type' => $post_type ) ); $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); _unregister_post_type( $post_type ); @@ -136,8 +136,8 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid_hierarchical() { - $parent_id = $this->factory->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) ); - $child_id = $this->factory->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) ); + $parent_id = self::$factory->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) ); + $child_id = self::$factory->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) ); $this->assertEquals( $parent_id, url_to_postid( get_permalink( $parent_id ) ) ); $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) ); @@ -145,26 +145,26 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid_hierarchical_with_matching_leaves() { - $parent_id = $this->factory->post->create( array( + $parent_id = self::$factory->post->create( array( 'post_name' => 'parent', 'post_type' => 'page', ) ); - $child_id_1 = $this->factory->post->create( array( + $child_id_1 = self::$factory->post->create( array( 'post_name' => 'child1', 'post_type' => 'page', 'post_parent' => $parent_id, ) ); - $child_id_2 = $this->factory->post->create( array( + $child_id_2 = self::$factory->post->create( array( 'post_name' => 'child2', 'post_type' => 'page', 'post_parent' => $parent_id, ) ); - $grandchild_id_1 = $this->factory->post->create( array( + $grandchild_id_1 = self::$factory->post->create( array( 'post_name' => 'grandchild', 'post_type' => 'page', 'post_parent' => $child_id_1, ) ); - $grandchild_id_2 = $this->factory->post->create( array( + $grandchild_id_2 = self::$factory->post->create( array( 'post_name' => 'grandchild', 'post_type' => 'page', 'post_parent' => $child_id_2, @@ -180,7 +180,7 @@ class Tests_Rewrite extends WP_UnitTestCase { update_option( 'home', home_url( '/example/' ) ); - $id = $this->factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) ); + $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) ); $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); $this->assertEquals( $id, url_to_postid( site_url('/example/examp' ) ) ); $this->assertEquals( $id, url_to_postid( '/example/examp/' ) ); @@ -244,7 +244,7 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid_dupe_path() { update_option( 'home', home_url('/example/') ); - $id = $this->factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) ); + $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) ); $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); $this->assertEquals( $id, url_to_postid( site_url( '/example/example/' ) ) ); @@ -258,7 +258,7 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid_home_url_collision() { update_option( 'home', home_url( '/example' ) ); - $this->factory->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) ); + self::$factory->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) ); // This url should NOT return a post ID $badurl = site_url( '/example-collision' ); @@ -277,10 +277,10 @@ class Tests_Rewrite extends WP_UnitTestCase { return false; } - $blog_id = $this->factory->blog->create( array( 'path' => '/example' ) ); + $blog_id = self::$factory->blog->create( array( 'path' => '/example' ) ); switch_to_blog( $blog_id ); - $this->factory->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) ); + self::$factory->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) ); // This url should NOT return a post ID $badurl = network_home_url( '/example-collision' ); @@ -294,7 +294,7 @@ class Tests_Rewrite extends WP_UnitTestCase { */ public function test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() { - $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $page_id ); @@ -313,9 +313,9 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() { $this->set_permalink_structure( '/%postname%/' ); - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); - $post_id = $this->factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); - + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); + $this->assertEquals( $post_id, url_to_postid( get_permalink( $post_id ) ) ); $this->set_permalink_structure(); @@ -327,9 +327,9 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() { $this->set_permalink_structure( '/%postname%/' ); - $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); - $post_id = $this->factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); - + $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); + $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); + $this->go_to( get_permalink( $post_id ) ); $this->assertTrue( is_single() ); diff --git a/tests/phpunit/tests/rewrite/numericSlugs.php b/tests/phpunit/tests/rewrite/numericSlugs.php index c8f3b28d23..652b28b131 100644 --- a/tests/phpunit/tests/rewrite/numericSlugs.php +++ b/tests/phpunit/tests/rewrite/numericSlugs.php @@ -9,7 +9,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); // Override the post/archive slug collision prevention in `wp_unique_post_slug()`. add_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ), 10, 6 ); @@ -23,7 +23,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { global $wpdb; $this->set_permalink_structure( '/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -51,7 +51,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { global $wpdb; $this->set_permalink_structure( '/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -76,7 +76,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_year_segment_collision_with_title() { $this->set_permalink_structure( '/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -92,7 +92,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_year_segment_collision_with_title() { $this->set_permalink_structure( '/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -106,7 +106,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_month_segment_collision_without_title() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -123,7 +123,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_month_segment_collision_without_title() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -138,7 +138,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_month_segment_collision_without_title_no_leading_zero() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -155,7 +155,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_month_segment_collision_without_title_no_leading_zero() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -170,7 +170,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_month_segment_collision_with_title() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -186,7 +186,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_month_segment_collision_with_title() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -200,7 +200,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_month_segment_collision_with_title_no_leading_zero() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -216,7 +216,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_month_segment_collision_with_title_no_leading_zero() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -230,7 +230,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_day_segment_collision_without_title() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -247,7 +247,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_day_segment_collision_without_title() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -262,7 +262,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_go_to_day_segment_collision_with_title() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -278,7 +278,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_url_to_postid_day_segment_collision_with_title() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -292,7 +292,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_numeric_slug_permalink_conflicts_should_only_be_resolved_for_the_main_query() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => rand_str(), @@ -314,7 +314,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { $this->set_permalink_structure( '/%year%/%postname%/' ); // Make sure a post is published in 2013/02, to avoid 404s. - $this->factory->post->create( array( + self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'foo', @@ -322,7 +322,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 'post_date' => '2013-02-01 01:00:00', ) ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'foo', @@ -342,7 +342,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); // Make sure a post is published on 2015/01/01, to avoid 404s. - $this->factory->post->create( array( + self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'foo', @@ -350,7 +350,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 'post_date' => '2015-01-02 01:00:00', ) ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'foo', @@ -369,7 +369,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_date_slug_collision_should_distinguish_valid_pagination_from_date() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'Page 0Page 1Page 2Page 3', @@ -385,7 +385,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_date_slug_collision_should_distinguish_too_high_pagination_from_date() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'Page 0Page 1Page 2Page 3', @@ -401,7 +401,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_date_slug_collision_should_not_require_pagination_query_var() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'Page 0Page 1Page 2Page 3', @@ -418,7 +418,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { public function test_date_slug_collision_should_be_ignored_when_pagination_var_is_present_but_post_does_not_have_multiple_pages() { $this->set_permalink_structure( '/%year%/%postname%/' ); - $id = $this->factory->post->create( array( + $id = self::$factory->post->create( array( 'post_author' => $this->author_id, 'post_status' => 'publish', 'post_content' => 'This post does not have pagination.', diff --git a/tests/phpunit/tests/rewrite/oldSlugRedirect.php b/tests/phpunit/tests/rewrite/oldSlugRedirect.php index 02323dc69e..97c187c435 100644 --- a/tests/phpunit/tests/rewrite/oldSlugRedirect.php +++ b/tests/phpunit/tests/rewrite/oldSlugRedirect.php @@ -12,7 +12,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create( array( + $this->post_id = self::$factory->post->create( array( 'post_title' => 'Foo Bar', 'post_name' => 'foo-bar', ) ); @@ -99,7 +99,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { public function test_old_slug_redirect_attachment() { $file = DIR_TESTDATA . '/images/canola.jpg'; - $attachment_id = $this->factory->attachment->create_object( $file, $this->post_id, array( + $attachment_id = self::$factory->attachment->create_object( $file, $this->post_id, array( 'post_mime_type' => 'image/jpeg', 'post_name' => 'my-attachment', ) ); diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 5a6af2e935..6c0447fd8e 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -34,13 +34,13 @@ class Tests_Taxonomy extends WP_UnitTestCase { } function test_get_the_taxonomies() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $taxes = get_the_taxonomies( $post_id ); $this->assertNotEmpty( $taxes ); $this->assertEquals( array( 'category' ), array_keys( $taxes ) ); - $id = $this->factory->tag->create(); + $id = self::$factory->tag->create(); wp_set_post_tags( $post_id, array( $id ) ); $taxes = get_the_taxonomies( $post_id ); @@ -53,7 +53,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { * @group 27238 */ public function test_get_the_taxonomies_term_template() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '%2$s' ) ); $this->assertEquals( 'Categories: Uncategorized.', $taxes['category'] ); @@ -64,7 +64,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { } function test_the_taxonomies() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); ob_start(); the_taxonomies( array( 'post' => $post_id ) ); @@ -79,7 +79,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { * @group 27238 */ function test_the_taxonomies_term_template() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $output = get_echo( 'the_taxonomies', array( array( 'post' => $post_id, 'term_template' => '%2$s' ) ) ); $this->assertEquals( 'Categories: Uncategorized.', $output ); @@ -262,25 +262,25 @@ class Tests_Taxonomy extends WP_UnitTestCase { } public function test_get_objects_in_term_should_return_objects_ids() { - $tag_id = $this->factory->tag->create(); - $cat_id = $this->factory->category->create(); + $tag_id = self::$factory->tag->create(); + $cat_id = self::$factory->category->create(); $posts_with_tag = array(); $posts_with_category = array(); for ( $i = 0; $i < 3; $i++ ) { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_set_post_tags( $post_id, array( $tag_id ) ); $posts_with_tag[] = $post_id; } for ( $i = 0; $i < 3; $i++ ) { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_set_post_categories( $post_id, array( $cat_id ) ); $posts_with_category[] = $post_id; } for ( $i = 0; $i < 3; $i++ ) { - $this->factory->post->create(); + self::$factory->post->create(); } $posts_with_terms = array_merge( $posts_with_tag, $posts_with_category ); @@ -295,7 +295,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { * @ticket 25706 */ function test_in_category() { - $post = $this->factory->post->create_and_get(); + $post = self::$factory->post->create_and_get(); // in_category() returns false when first parameter is empty() $this->assertFalse( in_category( '', $post ) ); @@ -346,7 +346,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { public function test_get_ancestors_taxonomy_non_hierarchical() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -358,18 +358,18 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t1, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t2, ) ); - $t4 = $this->factory->term->create( array( + $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t1, ) ); @@ -380,7 +380,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { public function test_get_ancestors_post_type_non_hierarchical() { register_post_type( 'wptests_pt' ); - $p = $this->factory->post->create( array( + $p = self::$factory->post->create( array( 'taxonomy' => 'wptests_pt', ) ); @@ -391,18 +391,18 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_post_type( 'wptests_pt', array( 'hierarchical' => true, ) ); - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_type' => 'wptests_pt', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'wptests_pt', 'post_parent' => $p1, ) ); - $p3 = $this->factory->post->create( array( + $p3 = self::$factory->post->create( array( 'post_type' => 'wptests_pt', 'post_parent' => $p2, ) ); - $p4 = $this->factory->post->create( array( + $p4 = self::$factory->post->create( array( 'post_type' => 'wptests_pt', 'post_parent' => $p1, ) ); @@ -418,10 +418,10 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_post_type( 'wptests_conflict', array( 'hierarchical' => true, ) ); - $p1 = $this->factory->post->create( array( + $p1 = self::$factory->post->create( array( 'post_type' => 'wptests_conflict', ) ); - $p2 = $this->factory->post->create( array( + $p2 = self::$factory->post->create( array( 'post_type' => 'wptests_conflict', 'post_parent' => $p1, ) ); @@ -429,10 +429,10 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'wptests_conflict', 'post', array( 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_conflict', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_conflict', 'parent' => $t1, ) ); @@ -451,11 +451,11 @@ class Tests_Taxonomy extends WP_UnitTestCase { 'public' => false, ) ); - $t = $this->factory->term->create_and_get( array( + $t = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax', ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); $this->go_to( '/?wptests_tax=' . $t->slug ); @@ -471,11 +471,11 @@ class Tests_Taxonomy extends WP_UnitTestCase { 'public' => false, ) ); - $t = $this->factory->term->create_and_get( array( + $t = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax', ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); $this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug ); diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 5a95037218..1c76e96b94 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -23,11 +23,11 @@ class Tests_Term extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $parent = $this->factory->term->create( array( + $parent = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $child = $this->factory->term->create( array( + $child = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $parent, 'slug' => 'foo', @@ -226,10 +226,10 @@ class Tests_Term extends WP_UnitTestCase { public function test_wp_set_object_terms_append_true() { register_taxonomy( 'wptests_tax', 'post' ); $p = self::$post_ids[0]; - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -247,10 +247,10 @@ class Tests_Term extends WP_UnitTestCase { public function test_wp_set_object_terms_append_false() { register_taxonomy( 'wptests_tax', 'post' ); $p = self::$post_ids[0]; - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -268,10 +268,10 @@ class Tests_Term extends WP_UnitTestCase { public function test_wp_set_object_terms_append_default_to_false() { register_taxonomy( 'wptests_tax', 'post' ); $p = self::$post_ids[0]; - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -364,7 +364,7 @@ class Tests_Term extends WP_UnitTestCase { */ function test_wp_add_remove_object_terms() { $posts = self::$post_ids; - $tags = $this->factory->tag->create_many( 5 ); + $tags = self::$factory->tag->create_many( 5 ); $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' ); $this->assertEquals( 1, count( $tt ) ); @@ -523,7 +523,7 @@ class Tests_Term extends WP_UnitTestCase { */ function test_object_term_cache_when_term_changes() { $post_id = self::$post_ids[0]; - $tag_id = $this->factory->tag->create( array( + $tag_id = self::$factory->tag->create( array( 'name' => 'Amaze Tag', 'description' => 'My Amazing Tag' ) ); @@ -553,7 +553,7 @@ class Tests_Term extends WP_UnitTestCase { public function test_get_the_terms_should_not_cache_wp_term_objects() { $p = self::$post_ids[0]; register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); // Prime the cache. @@ -572,7 +572,7 @@ class Tests_Term extends WP_UnitTestCase { public function test_get_the_terms_should_return_wp_term_objects_from_cache() { $p = self::$post_ids[0]; register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); // Prime the cache. @@ -618,11 +618,11 @@ class Tests_Term extends WP_UnitTestCase { * @ticket 19205 */ function test_orphan_category() { - $cat_id1 = $this->factory->category->create(); + $cat_id1 = self::$factory->category->create(); wp_delete_category( $cat_id1 ); - $cat_id2 = $this->factory->category->create( array( 'parent' => $cat_id1 ) ); + $cat_id2 = self::$factory->category->create( array( 'parent' => $cat_id1 ) ); $this->assertWPError( $cat_id2 ); } } diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 26f1507fd4..088a7fe321 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -15,15 +15,15 @@ class Tests_Term_Cache extends WP_UnitTestCase { */ function test_category_children_cache() { // Test with only one Parent => Child - $term_id1 = $this->factory->category->create(); - $term_id1_child = $this->factory->category->create( array( 'parent' => $term_id1 ) ); + $term_id1 = self::$factory->category->create(); + $term_id1_child = self::$factory->category->create( array( 'parent' => $term_id1 ) ); $hierarchy = _get_term_hierarchy( 'category' ); $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); // Add another Parent => Child - $term_id2 = $this->factory->category->create(); - $term_id2_child = $this->factory->category->create( array( 'parent' => $term_id2 ) ); + $term_id2 = self::$factory->category->create(); + $term_id2_child = self::$factory->category->create( array( 'parent' => $term_id2 ) ); $hierarchy = _get_term_hierarchy( 'category' ); $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy ); @@ -33,8 +33,8 @@ class Tests_Term_Cache extends WP_UnitTestCase { * @ticket 22526 */ function test_category_name_change() { - $term = $this->factory->category->create_and_get( array( 'name' => 'Foo' ) ); - $post_id = $this->factory->post->create(); + $term = self::$factory->category->create_and_get( array( 'name' => 'Foo' ) ); + $post_id = self::$factory->post->create(); wp_set_post_categories( $post_id, $term->term_id ); $post = get_post( $post_id ); @@ -98,7 +98,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $term = $this->factory->term->create( array( + $term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -124,7 +124,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $term = $this->factory->term->create( array( + $term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -151,7 +151,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $term = $this->factory->term->create( array( + $term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -182,7 +182,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 5, array( + $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax', ) ); diff --git a/tests/phpunit/tests/term/categoryExists.php b/tests/phpunit/tests/term/categoryExists.php index 5f973d4437..ff1e39d2e8 100644 --- a/tests/phpunit/tests/term/categoryExists.php +++ b/tests/phpunit/tests/term/categoryExists.php @@ -5,12 +5,12 @@ class Tests_Term_CategoryExists extends WP_UnitTestCase { * @ticket 30975 */ public function test_category_exists_should_return_only_top_level_categories_when_parent_is_0() { - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'name' => 'Foo', 'parent' => $c1, ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Foo', ) ); @@ -24,12 +24,12 @@ class Tests_Term_CategoryExists extends WP_UnitTestCase { */ public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_1() { // Foo child of c1 is created first. - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'name' => 'Foo', 'parent' => $c1, ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Foo', ) ); @@ -43,11 +43,11 @@ class Tests_Term_CategoryExists extends WP_UnitTestCase { */ public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_2() { // Top-level Foo is created first. - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'name' => 'Foo', ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Foo', 'parent' => $c1, ) ); @@ -61,12 +61,12 @@ class Tests_Term_CategoryExists extends WP_UnitTestCase { * @ticket 30975 */ public function test_category_exists_should_respect_nonempty_parent() { - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'name' => 'Foo', 'parent' => $c1, ) ); - $c3 = $this->factory->category->create( array( + $c3 = self::$factory->category->create( array( 'name' => 'Foo', ) ); diff --git a/tests/phpunit/tests/term/getEditTermLink.php b/tests/phpunit/tests/term/getEditTermLink.php index 610f24696e..3fa0ae1436 100644 --- a/tests/phpunit/tests/term/getEditTermLink.php +++ b/tests/phpunit/tests/term/getEditTermLink.php @@ -6,12 +6,12 @@ class Tests_Term_GetEditTermLink extends WP_UnitTestCase { public function setUp() { parent::setUp(); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); register_taxonomy( 'wptests_tax', 'post' ); } public function test_get_edit_term_link_default() { - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', ) ); @@ -25,7 +25,7 @@ class Tests_Term_GetEditTermLink extends WP_UnitTestCase { * @ticket 32786 */ public function test_get_edit_term_link_invalid_id() { - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', ) ); diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index b7f897374c..481627c463 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -24,7 +24,7 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { public function test_passing_term_object_should_skip_database_query_when_filter_property_is_empty() { global $wpdb; - $term = $this->factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); clean_term_cache( $term->term_id, 'wptests_tax' ); $num_queries = $wpdb->num_queries; @@ -46,7 +46,7 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { public function test_cache_should_be_populated_by_successful_fetch() { global $wpdb; - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); clean_term_cache( $t, 'wptests_tax' ); // Prime cache. @@ -60,19 +60,19 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { } public function test_output_object() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', OBJECT ) ); } public function test_output_array_a() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $term = get_term( $t, 'wptests_tax', ARRAY_A ); $this->assertInternalType( 'array', $term ); $this->assertTrue( isset( $term['term_id'] ) ); } public function test_output_array_n() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $term = get_term( $t, 'wptests_tax', ARRAY_N ); $this->assertInternalType( 'array', $term ); $this->assertFalse( isset( $term['term_id'] ) ); @@ -82,7 +82,7 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { } public function test_output_should_fall_back_to_object_for_invalid_input() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', 'foo' ) ); } @@ -92,7 +92,7 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { public function test_numeric_properties_should_be_cast_to_ints() { global $wpdb; - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); // Get raw data from the database. $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $t ) ); diff --git a/tests/phpunit/tests/term/getTermBy.php b/tests/phpunit/tests/term/getTermBy.php index 8debf8fd10..7d66b6e7c7 100644 --- a/tests/phpunit/tests/term/getTermBy.php +++ b/tests/phpunit/tests/term/getTermBy.php @@ -28,7 +28,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); $slug = 'ńaș'; - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'slug' => $slug, 'taxonomy' => 'wptests_tax', ) ); @@ -44,7 +44,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $term = get_term( $t, 'wptests_tax' ); $new_ttid = $term->term_taxonomy_id + 1; @@ -67,7 +67,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo', ) ); diff --git a/tests/phpunit/tests/term/getTermField.php b/tests/phpunit/tests/term/getTermField.php index 9b7d55aa1e..c616f419e6 100644 --- a/tests/phpunit/tests/term/getTermField.php +++ b/tests/phpunit/tests/term/getTermField.php @@ -17,7 +17,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { * @ticket 34245 */ public function test_get_term_field_should_not_return_error_for_empty_taxonomy() { - $term = $this->factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); $found = get_term_field( 'taxonomy', $term->term_id, '' ); $this->assertNotWPError( $found ); @@ -28,7 +28,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { * @ticket 34245 */ public function test_get_term_field_supplying_a_taxonomy() { - $term = $this->factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); $found = get_term_field( 'taxonomy', $term->term_id, $term->taxonomy ); $this->assertSame( $this->taxonomy, $found ); @@ -38,7 +38,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { * @ticket 34245 */ public function test_get_term_field_supplying_no_taxonomy() { - $term = $this->factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); $found = get_term_field( 'taxonomy', $term->term_id ); $this->assertSame( $this->taxonomy, $found ); @@ -48,7 +48,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { * @ticket 34245 */ public function test_get_term_field_should_accept_a_WP_Term_object_or_a_term_id() { - $term = $this->factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); $this->assertInstanceOf( 'WP_Term', $term ); $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) ); @@ -59,7 +59,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { * @ticket 34245 */ public function test_get_term_field_invalid_taxonomy_should_return_WP_Error() { - $term = $this->factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); + $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); $found = get_term_field( 'taxonomy', $term, 'foo-taxonomy' ); $this->assertWPError( $found ); diff --git a/tests/phpunit/tests/term/getTermLink.php b/tests/phpunit/tests/term/getTermLink.php index 7ba2488bfb..bd6c987b91 100644 --- a/tests/phpunit/tests/term/getTermLink.php +++ b/tests/phpunit/tests/term/getTermLink.php @@ -12,11 +12,11 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { } public function test_integer_should_be_interpreted_as_term_id() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => $t1, ) ); @@ -28,11 +28,11 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { } public function test_numeric_string_should_be_interpreted_as_term_slug() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'foo', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => $t1, ) ); @@ -49,7 +49,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { } public function test_category_should_use_cat_query_var_with_term_id() { - $c = $this->factory->category->create(); + $c = self::$factory->category->create(); $actual = get_term_link( $c, 'category' ); $this->assertContains( 'cat=' . $c, $actual ); @@ -60,7 +60,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { 'query_var' => 'foo', ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'bar', ) ); @@ -74,7 +74,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { 'query_var' => false, ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'bar', ) ); @@ -97,12 +97,12 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { flush_rewrite_rules(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'term1', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'term2', 'parent' => $t1, @@ -126,12 +126,12 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase { flush_rewrite_rules(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'term1', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'term2', 'parent' => $t1, diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 52ca4453cf..bdc3146a9c 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -105,7 +105,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 23506 */ function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() { - $term_id = $this->factory->tag->create(); + $term_id = self::$factory->tag->create(); $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); $this->assertEquals( $term_id, reset( $terms )->term_id ); } @@ -114,8 +114,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 13661 */ function test_get_terms_fields() { - $term_id1 = $this->factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); - $term_id2 = $this->factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) ); + $term_id1 = self::$factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); + $term_id2 = self::$factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) ); $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) ); $this->assertEquals( array( @@ -148,8 +148,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { function test_get_terms_include_exclude() { global $wpdb; - $term_id1 = $this->factory->tag->create(); - $term_id2 = $this->factory->tag->create(); + $term_id1 = self::$factory->tag->create(); + $term_id2 = self::$factory->tag->create(); $inc_terms = get_terms( 'post_tag', array( 'include' => array( $term_id1, $term_id2 ), 'hide_empty' => false @@ -179,7 +179,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_exclude_with_hierarchical_true_for_non_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); @@ -202,10 +202,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $term_id_uncategorized = get_option( 'default_category' ); - $term_id1 = $this->factory->category->create(); - $term_id11 = $this->factory->category->create( array( 'parent' => $term_id1 ) ); - $term_id2 = $this->factory->category->create(); - $term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) ); + $term_id1 = self::$factory->category->create(); + $term_id11 = self::$factory->category->create( array( 'parent' => $term_id1 ) ); + $term_id2 = self::$factory->category->create(); + $term_id22 = self::$factory->category->create( array( 'parent' => $term_id2 ) ); $terms = get_terms( 'category', array( 'exclude' => $term_id_uncategorized, @@ -228,8 +228,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 13992 */ function test_get_terms_search() { - $term_id1 = $this->factory->tag->create( array( 'slug' => 'burrito' ) ); - $term_id2 = $this->factory->tag->create( array( 'name' => 'Wilbur' ) ); + $term_id1 = self::$factory->tag->create( array( 'slug' => 'burrito' ) ); + $term_id2 = self::$factory->tag->create( array( 'name' => 'Wilbur' ) ); $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) ); $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms ); @@ -239,8 +239,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 8214 */ function test_get_terms_like() { - $term_id1 = $this->factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) ); - $term_id2 = $this->factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) ); + $term_id1 = self::$factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) ); + $term_id2 = self::$factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) ); $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) ); $this->assertEqualSets( array( $term_id1 ), $terms ); @@ -274,43 +274,43 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $tax = 'food'; register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); - $cheese = $this->factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); + $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); - $cheddar = $this->factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); + $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); - $post_ids = $this->factory->post->create_many( 2 ); + $post_ids = self::$factory->post->create_many( 2 ); foreach ( $post_ids as $id ) { wp_set_post_terms( $id, $cheddar, $tax ); } $term = get_term( $cheddar, $tax ); $this->assertEquals( 2, $term->count ); - $brie = $this->factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) ); - $post_id = $this->factory->post->create(); + $brie = self::$factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) ); + $post_id = self::$factory->post->create(); wp_set_post_terms( $post_id, $brie, $tax ); $term = get_term( $brie, $tax ); $this->assertEquals( 1, $term->count ); - $crackers = $this->factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) ); + $crackers = self::$factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) ); - $butter = $this->factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) ); - $post_ids = $this->factory->post->create_many( 1 ); + $butter = self::$factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) ); + $post_ids = self::$factory->post->create_many( 1 ); foreach ( $post_ids as $id ) { wp_set_post_terms( $id, $butter, $tax ); } $term = get_term( $butter, $tax ); $this->assertEquals( 1, $term->count ); - $multigrain = $this->factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) ); - $post_ids = $this->factory->post->create_many( 1 ); + $multigrain = self::$factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) ); + $post_ids = self::$factory->post->create_many( 1 ); foreach ( $post_ids as $id ) { wp_set_post_terms( $id, $multigrain, $tax ); } $term = get_term( $multigrain, $tax ); $this->assertEquals( 1, $term->count ); - $fruit = $this->factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) ); - $cranberries = $this->factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) ); + $fruit = self::$factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) ); + $cranberries = self::$factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) ); $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); $this->assertEquals( 2, count( $terms ) ); @@ -324,10 +324,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $tax = 'food'; register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); - $cheese = $this->factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); - $cheddar = $this->factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); - $spread = $this->factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) ); - $post_id = $this->factory->post->create(); + $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); + $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); + $spread = self::$factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) ); + $post_id = self::$factory->post->create(); wp_set_post_terms( $post_id, $spread, $tax ); $term = get_term( $spread, $tax ); $this->assertEquals( 1, $term->count ); @@ -348,10 +348,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $parent = 0; $t = array(); foreach ( range( 1, 7 ) as $depth ) { - $t[$depth] = $this->factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) ); + $t[$depth] = self::$factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) ); $parent = $t[$depth]; } - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_set_post_terms( $post_id, $t[7], $tax ); $term = get_term( $t[7], $tax ); $this->assertEquals( 1, $term->count ); @@ -367,8 +367,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 27123 */ function test_get_terms_child_of() { - $parent = $this->factory->category->create(); - $child = $this->factory->category->create( array( 'parent' => $parent ) ); + $parent = self::$factory->category->create(); + $child = self::$factory->category->create( array( 'parent' => $parent ) ); $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) ); $this->assertEquals( 1, count( $terms ) ); @@ -382,7 +382,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); $num_queries = $wpdb->num_queries; @@ -402,9 +402,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( 'fields' => 'ids', @@ -440,9 +440,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test__get_term_children_handles_cycles() { remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( 'parent' => $c1 ) ); - $c3 = $this->factory->category->create( array( 'parent' => $c2 ) ); + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); + $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); @@ -459,9 +459,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test__get_term_children_handles_cycles_when_terms_argument_contains_objects() { remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); - $c1 = $this->factory->category->create_and_get(); - $c2 = $this->factory->category->create_and_get( array( 'parent' => $c1->term_id ) ); - $c3 = $this->factory->category->create_and_get( array( 'parent' => $c2->term_id ) ); + $c1 = self::$factory->category->create_and_get(); + $c2 = self::$factory->category->create_and_get( array( 'parent' => $c1->term_id ) ); + $c3 = self::$factory->category->create_and_get( array( 'parent' => $c2->term_id ) ); wp_update_term( $c1->term_id, 'category', array( 'parent' => $c3->term_id ) ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); @@ -472,8 +472,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { } public function test_get_terms_by_slug() { - $t1 = $this->factory->tag->create( array( 'slug' => 'foo' ) ); - $t2 = $this->factory->tag->create( array( 'slug' => 'bar' ) ); + $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); + $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); $found = get_terms( 'post_tag', array( 'hide_empty' => false, @@ -488,9 +488,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 23636 */ public function test_get_terms_by_multiple_slugs() { - $t1 = $this->factory->tag->create( array( 'slug' => 'foo' ) ); - $t2 = $this->factory->tag->create( array( 'slug' => 'bar' ) ); - $t3 = $this->factory->tag->create( array( 'slug' => 'barry' ) ); + $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); + $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); + $t3 = self::$factory->tag->create( array( 'slug' => 'barry' ) ); $found = get_terms( 'post_tag', array( 'hide_empty' => false, @@ -505,8 +505,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 30611 */ public function test_get_terms_by_name() { - $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) ); - $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) ); + $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); + $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); $found = get_terms( 'post_tag', array( 'hide_empty' => false, @@ -521,9 +521,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 30611 */ public function test_get_terms_by_multiple_names() { - $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) ); - $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) ); - $t3 = $this->factory->tag->create( array( 'name' => 'Barry' ) ); + $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); + $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); + $t3 = self::$factory->tag->create( array( 'name' => 'Barry' ) ); $found = get_terms( 'post_tag', array( 'hide_empty' => false, @@ -540,7 +540,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_name_should_match_encoded_html_entities() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo & Bar', 'slug' => 'foo-and-bar', @@ -569,9 +569,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // If run on a flat hierarchy it should return everything. $flat_tax = 'countries'; register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) ); - $australia = $this->factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) ); - $china = $this->factory->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) ); - $tanzania = $this->factory->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) ); + $australia = self::$factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) ); + $china = self::$factory->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) ); + $tanzania = self::$factory->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) ); $terms = get_terms( $flat_tax, array( 'childless' => true, @@ -601,20 +601,20 @@ class Tests_Term_getTerms extends WP_UnitTestCase { PEI */ // Level 1 - $canada = $this->factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); + $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); // Level 2 - $ontario = $this->factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); - $quebec = $this->factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); - $pei = $this->factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) ); + $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); + $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); + $pei = self::$factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) ); // Level 3 - $toronto = $this->factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) ); - $ottawa = $this->factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) ); - $montreal = $this->factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); + $toronto = self::$factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) ); + $ottawa = self::$factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) ); + $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); // Level 4 - $nepean = $this->factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) ); + $nepean = self::$factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) ); $terms = get_terms( $tax, array( 'childless' => true, @@ -633,18 +633,18 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); // Level 1 - $canada = $this->factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); + $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); // Level 2 - $ontario = $this->factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); - $quebec = $this->factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); + $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); + $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); // Level 3 - $laval = $this->factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) ); - $montreal = $this->factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); + $laval = self::$factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) ); + $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); // Level 4 - $dorval = $this->factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) ); + $dorval = self::$factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) ); $terms = get_terms( $tax, array( 'childless' => true, @@ -663,10 +663,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t4 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) ); $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( 'fields' => 'ids', @@ -1098,15 +1098,15 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) ); - $t4 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t5 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) ); - $t6 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) ); + $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t5 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) ); + $t6 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $t3, 'wptests_tax1' ); wp_set_object_terms( $p, $t6, 'wptests_tax2' ); @@ -1140,10 +1140,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $tax = 'wptests_tax'; register_taxonomy( $tax, 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => $tax ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => $tax ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => $tax ) ); - $t4 = $this->factory->term->create( array( 'taxonomy' => $tax ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); + $t4 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); $found = get_terms( $tax, array( 'fields' => 'ids', @@ -1164,10 +1164,10 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $tax = 'wptests_tax'; register_taxonomy( $tax, 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) ); - $t4 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) ); + $t4 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) ); $found = get_terms( $tax, array( 'fields' => 'ids', @@ -1185,15 +1185,15 @@ class Tests_Term_getTerms extends WP_UnitTestCase { */ public function test_orderby_term_id() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'AAA', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'ZZZ', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'JJJ', ) ); @@ -1243,7 +1243,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_hierarchical_false_with_child_of_and_direct_child() { $initial_terms = $this->create_hierarchical_terms(); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_set_post_terms( $post_id, array( $initial_terms['seven_term']['term_id'] ), @@ -1323,7 +1323,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); $num_queries = $wpdb->num_queries; @@ -1343,9 +1343,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( 'fields' => 'ids', @@ -1395,16 +1395,16 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_pad_counts() { register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) ); - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_1', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_1', 'parent' => $t1, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_1', 'parent' => $t2, ) ); @@ -1436,14 +1436,14 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_pad_counts_should_not_recurse_infinitely_when_term_hierarchy_has_a_loop() { remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); - $c1 = $this->factory->category->create(); - $c2 = $this->factory->category->create( array( 'parent' => $c1 ) ); - $c3 = $this->factory->category->create( array( 'parent' => $c2 ) ); + $c1 = self::$factory->category->create(); + $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); + $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); wp_set_post_terms( $posts[0], $c1, 'category' ); wp_set_post_terms( $posts[1], $c2, 'category' ); wp_set_post_terms( $posts[2], $c3, 'category' ); @@ -1466,11 +1466,11 @@ class Tests_Term_getTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => false ) ); register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' ); wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' ); wp_set_object_terms( $posts[2], $t3, 'wptests_tax2' ); @@ -1499,7 +1499,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'bar' ); @@ -1525,7 +1525,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'bar' ); @@ -1550,7 +1550,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { */ public function test_meta_query() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'baz' ); @@ -1575,7 +1575,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { */ public function test_should_return_wp_term_objects() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); $found = get_terms( 'wptests_tax', array( 'hide_empty' => false, @@ -1597,7 +1597,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); // Prime the cache. get_terms( 'wptests_tax', array( @@ -1628,7 +1628,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); $found = get_terms( 'wptests_tax', array( 'hide_empty' => false, @@ -1644,13 +1644,13 @@ class Tests_Term_getTerms extends WP_UnitTestCase { protected function create_hierarchical_terms_and_posts() { $terms = array(); - $terms['parent1'] = $this->factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) ); - $terms['parent2'] = $this->factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) ); - $terms['child1'] = $this->factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); - $terms['child2'] = $this->factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); - $terms['grandchild1'] = $this->factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) ); + $terms['parent1'] = self::$factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) ); + $terms['parent2'] = self::$factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) ); + $terms['child1'] = self::$factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); + $terms['child2'] = self::$factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); + $terms['grandchild1'] = self::$factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_set_post_terms( $post_id, $terms['parent2'], 'hierarchical_fields', true ); wp_set_post_terms( $post_id, $terms['child1'], 'hierarchical_fields', true ); @@ -1714,8 +1714,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // Ensure child terms are not empty - $first_post_id = $this->factory->post->create(); - $second_post_id = $this->factory->post->create(); + $first_post_id = self::$factory->post->create(); + $second_post_id = self::$factory->post->create(); wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' ); wp_set_post_terms( $second_post_id, array( $six_term['term_id'] ), 'category' ); @@ -1731,7 +1731,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { } protected function set_up_three_posts_and_tags() { - $posts = $this->factory->post->create_many( 3, array( 'post_type' => 'post' ) ); + $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) ); foreach ( $posts as $post ) { wp_set_object_terms( $post, rand_str(), 'post_tag' ); } diff --git a/tests/phpunit/tests/term/isObjectInTerm.php b/tests/phpunit/tests/term/isObjectInTerm.php index be526aee7d..2e65a71693 100644 --- a/tests/phpunit/tests/term/isObjectInTerm.php +++ b/tests/phpunit/tests/term/isObjectInTerm.php @@ -7,10 +7,10 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { public function test_terms_are_ints() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, $t2 ) ) ); @@ -22,10 +22,10 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { public function test_terms_are_strings_and_match_term_id() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); $t1_str = (string) $t1; @@ -40,10 +40,10 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { public function test_terms_are_strings_and_match_term_name() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'Foo', 'Bar' ) ) ); @@ -55,10 +55,10 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { public function test_terms_are_strings_and_match_term_slug() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'foo', 'bar' ) ) ); @@ -70,10 +70,10 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { public function test_terms_contain_strings_and_ints_and_match_term_id_as_int() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, 'bar' ) ) ); @@ -87,9 +87,9 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { */ public function test_should_not_return_true_if_term_name_begins_with_existing_term_id() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $post_ID = $this->factory->post->create(); + $post_ID = self::$factory->post->create(); wp_set_object_terms( $post_ID, $t, 'wptests_tax' ); $int_tax_name = $t . '_term_name'; @@ -108,7 +108,7 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); $o = 12345; wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); @@ -129,7 +129,7 @@ class Tests_IsObjectInTerm extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); $o = 12345; wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 270eb4bc41..dc96fcdf7e 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -12,33 +12,33 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_add() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) ); } public function test_add_unique() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) ); $this->assertFalse( add_term_meta( $t, 'foo', 'bar', true ) ); } public function test_delete() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); $this->assertTrue( delete_term_meta( $t, 'foo' ) ); } public function test_delete_with_invalid_meta_key_should_return_false() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $this->assertFalse( delete_term_meta( $t, 'foo' ) ); } public function test_delete_should_respect_meta_value() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); add_term_meta( $t, 'foo', 'baz' ); @@ -49,7 +49,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_get_with_no_key_should_fetch_all_keys() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); add_term_meta( $t, 'foo1', 'baz' ); @@ -63,7 +63,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_get_with_key_should_fetch_all_for_key() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); add_term_meta( $t, 'foo', 'baz' ); add_term_meta( $t, 'foo1', 'baz' ); @@ -75,7 +75,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_get_should_respect_single_true() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); add_term_meta( $t, 'foo', 'baz' ); @@ -84,7 +84,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_update_should_pass_to_add_when_no_value_exists_for_key() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $actual = update_term_meta( $t, 'foo', 'bar' ); $this->assertInternalType( 'int', $actual ); @@ -95,7 +95,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_update_should_return_true_when_updating_existing_value_for_key() { - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $t, 'foo', 'bar' ); @@ -109,17 +109,17 @@ class Tests_Term_Meta extends WP_UnitTestCase { public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop() { global $wpdb; - $p = $this->factory->post->create( array( 'post_status' => 'publish' ) ); + $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $terms, 'wptests_tax' ); foreach ( $terms as $t ) { add_term_meta( $t, 'foo', 'bar' ); } // Create another term, which should *not* be lazy loaded because it's unattached. - $orphan_term = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $orphan_term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $orphan_term, 'foo', 'bar' ); // Force results to be cached, even when using extended cache. @@ -154,9 +154,9 @@ class Tests_Term_Meta extends WP_UnitTestCase { public function test_term_meta_should_be_lazy_loaded_only_for_the_queries_in_which_the_term_has_posts() { global $wpdb; - $posts = $this->factory->post->create_many( 3, array( 'post_status' => 'publish' ) ); + $posts = self::$factory->post->create_many( 3, array( 'post_status' => 'publish' ) ); register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $posts[0], array( $terms[0], $terms[1] ), 'wptests_tax' ); wp_set_object_terms( $posts[1], array( $terms[2], $terms[3] ), 'wptests_tax' ); @@ -201,7 +201,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_adding_term_meta_should_bust_get_terms_cache() { - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); @@ -236,7 +236,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_updating_term_meta_should_bust_get_terms_cache() { - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'baz' ); @@ -272,7 +272,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { } public function test_deleting_term_meta_should_bust_get_terms_cache() { - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php index 17786fea7c..bc863b12c6 100644 --- a/tests/phpunit/tests/term/query.php +++ b/tests/phpunit/tests/term/query.php @@ -125,9 +125,9 @@ class Tests_Tax_Query extends WP_UnitTestCase { } public function test_transform_query_resulting_field_sanitized() { - $t1 = $this->factory->category->create( array( 'slug' => 'foo', ) ); - $t2 = $this->factory->category->create( array( 'slug' => 'bar', ) ); - $p = $this->factory->post->create(); + $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) ); + $t2 = self::$factory->category->create( array( 'slug' => 'bar', ) ); + $p = self::$factory->post->create(); wp_set_post_categories( $p, $t1 ); $tq1 = new WP_Tax_Query( array( @@ -150,8 +150,8 @@ class Tests_Tax_Query extends WP_UnitTestCase { } public function test_transform_query_field_slug() { - $t1 = $this->factory->category->create( array( 'slug' => 'foo', ) ); - $p = $this->factory->post->create(); + $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) ); + $p = self::$factory->post->create(); $tt_ids = wp_set_post_categories( $p, $t1 ); $tq = new WP_Tax_Query( array( @@ -168,8 +168,8 @@ class Tests_Tax_Query extends WP_UnitTestCase { } public function test_transform_query_field_name() { - $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); - $p = $this->factory->post->create(); + $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); + $p = self::$factory->post->create(); $tt_ids = wp_set_post_categories( $p, $t1 ); $tq = new WP_Tax_Query( array( @@ -186,8 +186,8 @@ class Tests_Tax_Query extends WP_UnitTestCase { } public function test_transform_query_field_term_taxonomy_id() { - $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); - $p = $this->factory->post->create(); + $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); + $p = self::$factory->post->create(); $tt_ids = wp_set_post_categories( $p, $t1 ); $tq = new WP_Tax_Query( array( @@ -204,8 +204,8 @@ class Tests_Tax_Query extends WP_UnitTestCase { } public function test_transform_query_field_term_taxonomy_default() { - $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); - $p = $this->factory->post->create(); + $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); + $p = self::$factory->post->create(); $tt_ids = wp_set_post_categories( $p, $t1 ); $tq = new WP_Tax_Query( array( @@ -240,13 +240,13 @@ class Tests_Tax_Query extends WP_UnitTestCase { public function test_get_sql_relation_or_operator_in() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -284,13 +284,13 @@ class Tests_Tax_Query extends WP_UnitTestCase { public function test_get_sql_relation_and_operator_in() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -327,13 +327,13 @@ class Tests_Tax_Query extends WP_UnitTestCase { public function test_get_sql_nested_relation_or_operator_in() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); diff --git a/tests/phpunit/tests/term/slashes.php b/tests/phpunit/tests/term/slashes.php index c597312f16..7183bdb6c8 100644 --- a/tests/phpunit/tests/term/slashes.php +++ b/tests/phpunit/tests/term/slashes.php @@ -8,7 +8,7 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); @@ -84,7 +84,7 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { 'post_tag' ); foreach ( $taxonomies as $taxonomy ) { - $id = $this->factory->term->create(array( + $id = self::$factory->term->create(array( 'taxonomy' => $taxonomy )); diff --git a/tests/phpunit/tests/term/termExists.php b/tests/phpunit/tests/term/termExists.php index 89d9e44ea9..d628b31a12 100644 --- a/tests/phpunit/tests/term/termExists.php +++ b/tests/phpunit/tests/term/termExists.php @@ -9,7 +9,7 @@ class Tests_TermExists extends WP_UnitTestCase { } public function test_term_exists_term_int_taxonomy_nonempty_term_exists() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'post_tag', ) ); @@ -22,7 +22,7 @@ class Tests_TermExists extends WP_UnitTestCase { } public function test_term_exists_term_int_taxonomy_nonempty_wrong_taxonomy() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'post_tag', ) ); @@ -30,7 +30,7 @@ class Tests_TermExists extends WP_UnitTestCase { } public function test_term_exists_term_int_taxonomy_empty_term_exists() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'post_tag', ) ); @@ -43,7 +43,7 @@ class Tests_TermExists extends WP_UnitTestCase { } public function test_term_exists_unslash_term() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'I "love" WordPress\'s taxonomy system', ) ); @@ -53,7 +53,7 @@ class Tests_TermExists extends WP_UnitTestCase { } public function test_term_exists_trim_term() { - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'post_tag', 'slug' => 'foo', ) ); @@ -84,11 +84,11 @@ class Tests_TermExists extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $parent_term = $this->factory->term->create( array( + $parent_term = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'parent' => $parent_term, 'slug' => 'child-term', @@ -110,11 +110,11 @@ class Tests_TermExists extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $parent_term = $this->factory->term->create( array( + $parent_term = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'parent' => $parent_term, 'slug' => 'child-term', @@ -132,11 +132,11 @@ class Tests_TermExists extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $parent_term = $this->factory->term->create( array( + $parent_term = self::$factory->term->create( array( 'taxonomy' => 'foo', ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'parent' => $parent_term, 'name' => 'Child Term', @@ -153,7 +153,7 @@ class Tests_TermExists extends WP_UnitTestCase { public function test_term_exists_taxonomy_nonempty_parent_empty_match_slug() { register_taxonomy( 'foo', 'post', array() ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'slug' => 'kewl-dudez', ) ); @@ -169,7 +169,7 @@ class Tests_TermExists extends WP_UnitTestCase { public function test_term_exists_taxonomy_nonempty_parent_empty_match_name() { register_taxonomy( 'foo', 'post', array() ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'name' => 'Kewl Dudez', ) ); @@ -185,7 +185,7 @@ class Tests_TermExists extends WP_UnitTestCase { public function test_term_exists_taxonomy_empty_parent_empty_match_slug() { register_taxonomy( 'foo', 'post', array() ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'name' => 'juicy-fruit', ) ); @@ -201,7 +201,7 @@ class Tests_TermExists extends WP_UnitTestCase { public function test_term_exists_taxonomy_empty_parent_empty_match_name() { register_taxonomy( 'foo', 'post', array() ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'foo', 'name' => 'Juicy Fruit', ) ); diff --git a/tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php b/tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php index c4b7611153..dee591881f 100644 --- a/tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php +++ b/tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php @@ -9,8 +9,8 @@ class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); $object_id = 567; @@ -33,9 +33,9 @@ class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { register_taxonomy( 'wptests_tax2', 'post' ); register_taxonomy( 'wptests_tax3', 'post' ); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); - $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax3' ) ); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax3' ) ); $object_id = 567; diff --git a/tests/phpunit/tests/term/wpDeleteTerm.php b/tests/phpunit/tests/term/wpDeleteTerm.php index 064528f281..f47caa4069 100644 --- a/tests/phpunit/tests/term/wpDeleteTerm.php +++ b/tests/phpunit/tests/term/wpDeleteTerm.php @@ -12,11 +12,11 @@ class Tests_Term_WpDeleteTerm extends WP_UnitTestCase { public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( + $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, array( $terms[0] ), 'wptests_tax' ); diff --git a/tests/phpunit/tests/term/wpGenerateTagCloud.php b/tests/phpunit/tests/term/wpGenerateTagCloud.php index aa8f957db3..7f5352da60 100644 --- a/tests/phpunit/tests/term/wpGenerateTagCloud.php +++ b/tests/phpunit/tests/term/wpGenerateTagCloud.php @@ -3,6 +3,8 @@ * @group taxonomy */ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { + protected $terms = array(); + /** * Testing when passed $tags array is empty * @@ -25,7 +27,11 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { * @param $args Options for `wp_generate_tag_cloud()`. */ function test_empty_tags_list_returned( $expected, $args ) { - $this->factory->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) ); + $term_ids = self::$factory->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) ); + $this->terms = array(); + foreach ( $term_ids as $term_id ) { + $this->terms[] = get_term( $term_id, 'post_tag' ); + } $tags = $this->retrieve_terms( array( 'number' => 4 ) ); $this->assertSame( $expected, wp_generate_tag_cloud( $tags, $args ) ); } @@ -64,116 +70,114 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { ); } + function test_hide_empty_false() { + $term_id = self::$factory->tag->create(); + $term = get_term( $term_id, 'post_tag' ); - /** - * Testing the various output for a single link - * in various formats - * - * @dataProvider single_link_data_provider - * - * @param int $create How many tags to create. - * @param array $get_terms_args What args we want to pass to retreve terms. - * @param mixed $expected Expected output from `wp_generate_tag_cloud()`. - * @param array $args Options for `wp_generate_tag_cloud()`. - * - */ - function test_wp_generate_tag_cloud( $create, $get_terms_args, $expected, $args ) { - $this->factory->term->create_many( $create, array( 'taxonomy' => 'post_tag' ) ); - $tags = $this->retrieve_terms( $get_terms_args ); - - $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, $args ) ); + $tags = $this->retrieve_terms( array( + 'number' => 1, + 'hide_empty' => false, + ) ); + $expected = "{$term->name}"; + $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, array( + 'hide_empty' => false, + ) ) ); } + function test_hide_empty_false_format_array() { + $term_id = self::$factory->tag->create(); + $term = get_term( $term_id, 'post_tag' ); - function single_link_data_provider() { - return array( - array( - 1, - array( - 'number' => 1, - 'hide_empty' => false, - ), - "Term 1", - array( - 'hide_empty' => false, - ), - ), + $tags = $this->retrieve_terms( array( + 'number' => 1, + 'hide_empty' => false, + 'format' => 'array', + ) ); - // Should return an array of links. - array( - 1, - array( - 'number' => 1, - 'hide_empty' => false, - ), - array( - "Term 1", - ), - array( - 'hide_empty' => false, - 'format' => 'array', - ), - ), + $expected = "{$term->name}"; + $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, array( + 'hide_empty' => false, + ) ) ); + } - // Should return a string containing a
    list of links. - array( - 1, - array( - 'number' => 1, - 'hide_empty' => false, - ), - "\n", - array( - 'hide_empty' => false, - 'format' => 'list', - ), - ), + function test_hide_empty_false_format_list() { + $term_id = self::$factory->tag->create(); + $term = get_term( $term_id, 'post_tag' ); - array( - 4, - array( - 'number' => 4, - 'hide_empty' => false, - ), - "Term 1\n". - "Term 2\n". - "Term 3\n". - "Term 4", - array( - 'hide_empty' => false, - ), - ), + $tags = $this->retrieve_terms( array( + 'number' => 1, + 'hide_empty' => false, + ) ); - array( - 4, - array( - 'number' => 4, - 'hide_empty' => false, - ), - "\n", - array( - 'hide_empty' => false, - 'format' => 'list', - ), - ), - ); + $expected = "\n"; + $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, array( + 'hide_empty' => false, + 'format' => 'list', + ) ) ); + } + + function test_hide_empty_false_multi() { + $term_ids = self::$factory->tag->create_many( 4 ); + $terms = array(); + foreach ( $term_ids as $term_id ) { + $terms[] = get_term( $term_id, 'post_tag' ); + } + + $tags = $this->retrieve_terms( array( + 'number' => 4, + 'order' => 'id', + 'hide_empty' => false, + ) ); + + $expected = "{$terms[0]->name}\n". + "{$terms[1]->name}\n". + "{$terms[2]->name}\n". + "{$terms[3]->name}"; + $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, array( + 'hide_empty' => false, + ) ) ); + } + + function test_hide_empty_false_multi_format_list() { + $term_ids = self::$factory->tag->create_many( 4 ); + $terms = array(); + foreach ( $term_ids as $term_id ) { + $terms[] = get_term( $term_id, 'post_tag' ); + } + + $tags = $this->retrieve_terms( array( + 'number' => 4, + 'orderby' => 'id', + 'hide_empty' => false, + ) ); + + $expected = "\n"; + + $this->assertEquals( $expected, wp_generate_tag_cloud( $tags, array( + 'hide_empty' => false, + 'format' => 'list', + ) ) ); } public function test_topic_count_text() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); - $posts = $this->factory->post->create_many( 2 ); + $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $this->terms = array(); + foreach ( $term_ids as $term_id ) { + $this->terms[] = get_term( $term_id, 'post_tag' ); + } + $posts = self::$factory->post->create_many( 2 ); - wp_set_post_terms( $posts[0], $terms, 'wptests_tax' ); - wp_set_post_terms( $posts[1], array( $terms[1] ), 'wptests_tax' ); + wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' ); + wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); $term_objects = $this->retrieve_terms( array( - 'include' => $terms, + 'include' => $term_ids, ), 'wptests_tax' ); $actual = wp_generate_tag_cloud( $term_objects, array( @@ -192,14 +196,18 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { public function test_topic_count_text_callback() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); - $posts = $this->factory->post->create_many( 2 ); + $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); + $this->terms = array(); + foreach ( $term_ids as $term_id ) { + $this->terms[] = get_term( $term_id, 'post_tag' ); + } + $posts = self::$factory->post->create_many( 2 ); - wp_set_post_terms( $posts[0], $terms, 'wptests_tax' ); - wp_set_post_terms( $posts[1], array( $terms[1] ), 'wptests_tax' ); + wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' ); + wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); $term_objects = $this->retrieve_terms( array( - 'include' => $terms, + 'include' => $term_ids, ), 'wptests_tax' ); $actual = wp_generate_tag_cloud( $term_objects, array( diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index 5ff2a000d2..3d7a90f8e8 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -13,7 +13,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_get_object_terms_by_slug() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $terms_1 = array('Foo', 'Bar', 'Baz'); $terms_1_slugs = array('foo', 'bar', 'baz'); @@ -31,10 +31,10 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 11003 */ public function test_should_not_filter_out_duplicate_terms_associated_with_different_objects() { - $post_id1 = $this->factory->post->create(); - $post_id2 = $this->factory->post->create(); - $cat_id = $this->factory->category->create(); - $cat_id2 = $this->factory->category->create(); + $post_id1 = self::$factory->post->create(); + $post_id2 = self::$factory->post->create(); + $cat_id = self::$factory->category->create(); + $cat_id2 = self::$factory->category->create(); wp_set_post_categories( $post_id1, array( $cat_id, $cat_id2 ) ); wp_set_post_categories( $post_id2, $cat_id ); @@ -54,7 +54,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 17646 */ public function test_should_return_objects_with_int_properties() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $term = wp_insert_term( 'one', $this->taxonomy ); wp_set_object_terms( $post_id, $term, $this->taxonomy ); @@ -73,7 +73,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 26339 */ public function test_references_should_be_reset_after_wp_get_object_terms_filter() { - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $terms_1 = array('foo', 'bar', 'baz'); wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); @@ -86,17 +86,17 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_orderby_name() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'AAA', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'ZZZ', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'JJJ', ) ); @@ -112,17 +112,17 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_orderby_count() { - $posts = $this->factory->post->create_many( 3 ); + $posts = self::$factory->post->create_many( 3 ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'AAA', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'ZZZ', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'JJJ', ) ); @@ -140,17 +140,17 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_orderby_slug() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'slug' => 'aaa', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'slug' => 'zzz', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'slug' => 'jjj', ) ); @@ -166,15 +166,15 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_orderby_term_group() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); @@ -195,15 +195,15 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_orderby_term_order() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); @@ -231,15 +231,15 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 28688 */ public function test_orderby_parent() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); @@ -269,15 +269,15 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax_2', 'post' ); register_taxonomy( 'wptests_tax_3', 'post' ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_3', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_2', ) ); @@ -297,15 +297,15 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 28688 */ public function test_orderby_tt_id() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); @@ -330,17 +330,17 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { } public function test_order_desc() { - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'AAA', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'ZZZ', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'name' => 'JJJ', ) ); @@ -360,22 +360,22 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 15675 */ public function test_parent() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'parent' => $t1, ) ); - $t4 = $this->factory->term->create( array( + $t4 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'parent' => $t2, ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy ); @@ -391,22 +391,22 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { * @ticket 15675 */ public function test_parent_0() { - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'parent' => $t1, ) ); - $t4 = $this->factory->term->create( array( + $t4 = self::$factory->term->create( array( 'taxonomy' => $this->taxonomy, 'parent' => $t2, ) ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy ); @@ -425,12 +425,12 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'bar' ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $terms, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax' ); @@ -451,12 +451,12 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'bar' ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $terms, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -477,13 +477,13 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { */ public function test_meta_query() { register_taxonomy( 'wptests_tax', 'post' ); - $terms = $this->factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); + $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); add_term_meta( $terms[0], 'foo', 'bar' ); add_term_meta( $terms[1], 'foo', 'bar' ); add_term_meta( $terms[2], 'foo', 'baz' ); add_term_meta( $terms[3], 'foob', 'ar' ); - $p = $this->factory->post->create(); + $p = self::$factory->post->create(); wp_set_object_terms( $p, $terms, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -503,8 +503,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { */ public function test_should_return_wp_term_objects_for_fields_all() { register_taxonomy( 'wptests_tax', 'post' ); - $p = $this->factory->post->create(); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $p = self::$factory->post->create(); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -522,8 +522,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { */ public function test_should_return_wp_term_objects_for_fields_all_with_object_id() { register_taxonomy( 'wptests_tax', 'post' ); - $p = $this->factory->post->create(); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $p = self::$factory->post->create(); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -543,8 +543,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { global $wpdb; register_taxonomy( 'wptests_tax', 'post' ); - $p = $this->factory->post->create(); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $p = self::$factory->post->create(); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -561,8 +561,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { */ public function test_object_id_should_not_be_cached_with_term_object() { register_taxonomy( 'wptests_tax', 'post' ); - $p = $this->factory->post->create(); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $p = self::$factory->post->create(); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $p, $t, 'wptests_tax' ); $found = wp_get_object_terms( $p, 'wptests_tax', array( @@ -585,9 +585,9 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { register_taxonomy( 'wptests_tax1', 'post' ); register_taxonomy( 'wptests_tax2', 'post' ); - $p = $this->factory->post->create(); - $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); - $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); + $p = self::$factory->post->create(); + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); wp_set_object_terms( $p, $t1, 'wptests_tax1' ); wp_set_object_terms( $p, $t2, 'wptests_tax2' ); @@ -611,8 +611,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { */ public function test_object_id_should_be_set_on_objects_that_share_terms() { register_taxonomy( 'wptests_tax', 'post' ); - $posts = $this->factory->post->create_many( 2 ); - $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); + $posts = self::$factory->post->create_many( 2 ); + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); wp_set_object_terms( $posts[0], $t, 'wptests_tax' ); wp_set_object_terms( $posts[1], $t, 'wptests_tax' ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 90fb4c4e27..18e3fd3e9e 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -160,25 +160,25 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { * @ticket 17689 */ public function test_wp_insert_term_duplicate_name() { - $term = $this->factory->tag->create_and_get( array( 'name' => 'Bozo' ) ); + $term = self::$factory->tag->create_and_get( array( 'name' => 'Bozo' ) ); $this->assertNotWPError( $term ); $this->assertTrue( empty( $term->errors ) ); // Test existing term name with unique slug - $term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) ); + $term1 = self::$factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) ); $this->assertNotWPError( $term1 ); // Test an existing term name - $term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) ); + $term2 = self::$factory->tag->create( array( 'name' => 'Bozo' ) ); $this->assertTrue( is_wp_error( $term2 ) ); $this->assertNotEmpty( $term2->errors ); // Test named terms ending in special characters - $term3 = $this->factory->tag->create( array( 'name' => 'T$' ) ); - $term4 = $this->factory->tag->create( array( 'name' => 'T$$' ) ); - $term5 = $this->factory->tag->create( array( 'name' => 'T$$$' ) ); - $term6 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) ); - $term7 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) ); + $term3 = self::$factory->tag->create( array( 'name' => 'T$' ) ); + $term4 = self::$factory->tag->create( array( 'name' => 'T$$' ) ); + $term5 = self::$factory->tag->create( array( 'name' => 'T$$$' ) ); + $term6 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) ); + $term7 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) ); $this->assertTrue( is_wp_error( $term7 ) ); $this->assertNotEmpty( $term7->errors ); $this->assertEquals( $term6, $term7->error_data['term_exists'] ); @@ -187,11 +187,11 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); // Test named terms with only special characters - $term8 = $this->factory->tag->create( array( 'name' => '$' ) ); - $term9 = $this->factory->tag->create( array( 'name' => '$$' ) ); - $term10 = $this->factory->tag->create( array( 'name' => '$$$' ) ); - $term11 = $this->factory->tag->create( array( 'name' => '$$$$' ) ); - $term12 = $this->factory->tag->create( array( 'name' => '$$$$' ) ); + $term8 = self::$factory->tag->create( array( 'name' => '$' ) ); + $term9 = self::$factory->tag->create( array( 'name' => '$$' ) ); + $term10 = self::$factory->tag->create( array( 'name' => '$$$' ) ); + $term11 = self::$factory->tag->create( array( 'name' => '$$$$' ) ); + $term12 = self::$factory->tag->create( array( 'name' => '$$$$' ) ); $this->assertTrue( is_wp_error( $term12 ) ); $this->assertNotEmpty( $term12->errors ); $this->assertEquals( $term11, $term12->error_data['term_exists'] ); @@ -199,21 +199,21 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) ); $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); - $term13 = $this->factory->tag->create( array( 'name' => 'A' ) ); + $term13 = self::$factory->tag->create( array( 'name' => 'A' ) ); $this->assertNotWPError( $term13 ); - $term14 = $this->factory->tag->create( array( 'name' => 'A' ) ); + $term14 = self::$factory->tag->create( array( 'name' => 'A' ) ); $this->assertTrue( is_wp_error( $term14 ) ); - $term15 = $this->factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); + $term15 = self::$factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); $this->assertNotWPError( $term15 ); - $term16 = $this->factory->tag->create( array( 'name' => 'A+' ) ); + $term16 = self::$factory->tag->create( array( 'name' => 'A+' ) ); $this->assertTrue( is_wp_error( $term16 ) ); - $term17 = $this->factory->tag->create( array( 'name' => 'A++' ) ); + $term17 = self::$factory->tag->create( array( 'name' => 'A++' ) ); $this->assertNotWPError( $term17 ); - $term18 = $this->factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); + $term18 = self::$factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); $this->assertNotWPError( $term18 ); - $term19 = $this->factory->tag->create( array( 'name' => 'A-' ) ); + $term19 = self::$factory->tag->create( array( 'name' => 'A-' ) ); $this->assertTrue( is_wp_error( $term19 ) ); - $term20 = $this->factory->tag->create( array( 'name' => 'A--' ) ); + $term20 = self::$factory->tag->create( array( 'name' => 'A--' ) ); $this->assertNotWPError( $term20 ); } @@ -222,7 +222,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_non_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -241,13 +241,13 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_in_non_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'taxonomy' => 'wptests_tax', @@ -266,7 +266,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_non_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -288,7 +288,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_non_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -305,7 +305,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -324,13 +324,13 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_at_same_hierarchy_level_in_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'taxonomy' => 'wptests_tax', @@ -349,15 +349,15 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_allow_duplicate_names_when_slug_is_a_duplicate_of_a_term_at_different_hierarchy_level_in_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create(); + $t2 = self::$factory->term->create(); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'parent' => $t2, @@ -381,7 +381,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -403,7 +403,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_hierarchical_taxonomy() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -419,7 +419,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_duplicate_slug_same_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -443,7 +443,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_duplicate_slug_different_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -473,7 +473,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', @@ -501,7 +501,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_alias_of_no_term_group() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $term_1 = get_term( $t1, 'wptests_tax' ); @@ -523,12 +523,12 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_alias_of_existing_term_group() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $term_1 = get_term( $t1, 'wptests_tax' ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'alias_of' => $term_1->slug, ) ); @@ -591,7 +591,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -623,11 +623,11 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_with_and_without_accents() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foó', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Foo', 'taxonomy' => 'wptests_tax', ) ); diff --git a/tests/phpunit/tests/term/wpUniqueTermSlug.php b/tests/phpunit/tests/term/wpUniqueTermSlug.php index c71523f4da..98bca8a7e5 100644 --- a/tests/phpunit/tests/term/wpUniqueTermSlug.php +++ b/tests/phpunit/tests/term/wpUniqueTermSlug.php @@ -11,7 +11,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { } public function test_unique_slug_should_be_unchanged() { - $term = $this->factory->term->create_and_get( array( + $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax1', 'name' => 'foo', 'slug' => 'foo', @@ -22,13 +22,13 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { } public function test_nonunique_slug_in_different_taxonomy_should_be_unchanged() { - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'name' => 'bar', 'slug' => 'bar', ) ); - $term2 = $this->factory->term->create( array( + $term2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'name' => 'foo', 'slug' => 'foo', @@ -40,13 +40,13 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { } public function test_nonunique_slug_in_same_nonhierarchical_taxonomy_should_be_changed() { - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'name' => 'bar', 'slug' => 'bar', ) ); - $term2 = $this->factory->term->create( array( + $term2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'name' => 'foo', 'slug' => 'foo', @@ -58,19 +58,19 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { } public function test_nonunique_slug_in_same_hierarchical_taxonomy_with_same_parent_should_be_suffixed_with_parent_slug() { - $parent = $this->factory->term->create( array( + $parent = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'parent-term', ) ); - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'name' => 'bar', 'slug' => 'bar', 'parent' => $parent, ) ); - $term2 = $this->factory->term->create( array( + $term2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'name' => 'foo', 'slug' => 'foo', @@ -83,19 +83,19 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { } public function test_nonunique_slug_in_same_hierarchical_taxonomy_at_different_level_of_hierarchy_should_be_suffixed_with_number() { - $parent = $this->factory->term->create( array( + $parent = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'slug' => 'parent-term', ) ); - $term1 = $this->factory->term->create( array( + $term1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'name' => 'bar', 'slug' => 'bar', 'parent' => $parent, ) ); - $term2 = $this->factory->term->create( array( + $term2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'name' => 'foo', 'slug' => 'foo', diff --git a/tests/phpunit/tests/term/wpUpdateTerm.php b/tests/phpunit/tests/term/wpUpdateTerm.php index 71495d7175..047fa9af05 100644 --- a/tests/phpunit/tests/term/wpUpdateTerm.php +++ b/tests/phpunit/tests/term/wpUpdateTerm.php @@ -20,7 +20,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_unslash_name() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -36,7 +36,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_unslash_description() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -52,7 +52,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_name_empty_string() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -76,7 +76,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { $this->assertNull( term_exists( $fake_term_id, 'wptests_tax' ) ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -94,7 +94,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_slug_empty_string_while_not_updating_name() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo Bar', ) ); @@ -110,7 +110,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_slug_empty_string_while_updating_name() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -126,7 +126,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_slug_set_slug() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -145,13 +145,13 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_should_not_create_duplicate_slugs_within_the_same_taxonomy() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'taxonomy' => 'wptests_tax', @@ -172,13 +172,13 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'bar', 'taxonomy' => 'wptests_tax_2', @@ -202,13 +202,13 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'taxonomy' => 'wptests_tax_2', @@ -232,20 +232,20 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'name' => 'Foo', 'slug' => 'foo', 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'name' => 'Bar', 'slug' => 'bar', 'taxonomy' => 'wptests_tax', 'parent' => $t1, ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'name' => 'Bar Child', 'slug' => 'bar-child', 'taxonomy' => 'wptests_tax', @@ -282,7 +282,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { array( '%d' ) ); - $posts = $this->factory->post->create_many( 2 ); + $posts = self::$factory->post->create_many( 2 ); wp_set_object_terms( $posts[0], array( 'Foo' ), 'wptests_tax' ); wp_set_object_terms( $posts[1], array( 'Foo' ), 'wptests_tax_2' ); @@ -302,7 +302,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_alias_of_no_term_group() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $term_1 = get_term( $t1, 'wptests_tax' ); @@ -323,12 +323,12 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_alias_of_existing_term_group() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $term_1 = get_term( $t1, 'wptests_tax' ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'alias_of' => $term_1->slug, ) ); @@ -359,7 +359,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_slug_same_as_old_slug() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo', ) ); @@ -377,11 +377,11 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_duplicate_slug_generated_due_to_empty_slug_param() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo-bar', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'not foo bar', ) ); @@ -402,14 +402,14 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); - $p = $this->factory->term->create( array( + $p = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo-bar', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -428,11 +428,11 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_duplicate_slug_failure() { register_taxonomy( 'wptests_tax', 'post' ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo-bar', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'my-old-slug', ) ); @@ -451,7 +451,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_should_return_term_id_and_term_taxonomy_id() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $found = wp_update_term( $t, 'wptests_tax', array( @@ -477,7 +477,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { */ public function test_wp_update_term_should_return_int_values_for_term_id_and_term_taxonomy_id() { register_taxonomy( 'wptests_tax', 'post' ); - $t = $this->factory->term->create( array( + $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); $found = wp_update_term( $t, 'wptests_tax', array( @@ -491,15 +491,15 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_should_clean_object_term_cache() { register_taxonomy( 'wptests_tax_for_post', 'post' ); register_taxonomy( 'wptests_tax_for_page', 'page' ); - $post = $this->factory->post->create(); - $page = $this->factory->post->create( array( + $post = self::$factory->post->create(); + $page = self::$factory->post->create( array( 'post_type' => 'page', ) ); - $t_for_post = $this->factory->term->create( array( + $t_for_post = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_for_post', ) ); - $t_for_page = $this->factory->term->create( array( + $t_for_page = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_for_page', ) ); @@ -527,10 +527,10 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', ) ); @@ -567,12 +567,12 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'parent-term', ) ); - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo', ) ); @@ -599,18 +599,18 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'hierarchical' => true, ) ); - $t1 = $this->factory->term->create( array( + $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'parent-term', ) ); // Same slug but in a different tax. - $t2 = $this->factory->term->create( array( + $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax_2', 'slug' => 'foo', ) ); - $t3 = $this->factory->term->create( array( + $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo', ) ); @@ -630,7 +630,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { * @ticket 31954 */ public function test_wp_update_term_with_null_get_term() { - $t = $this->factory->term->create( array( 'taxonomy' => 'category' ) ); + $t = self::$factory->term->create( array( 'taxonomy' => 'category' ) ); $found = wp_update_term( $t, 'post_tag', array( 'slug' => 'foo' ) ); $this->assertWPError( $found ); diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php index 83cc707cd4..baae9d6f6e 100644 --- a/tests/phpunit/tests/url.php +++ b/tests/phpunit/tests/url.php @@ -272,8 +272,8 @@ class Tests_URL extends WP_UnitTestCase { public function test_get_adjacent_post() { $now = time(); - $post_id = $this->factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); - $post_id2 = $this->factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); + $post_id = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); + $post_id2 = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); if ( ! isset( $GLOBALS['post'] ) ) $GLOBALS['post'] = null; @@ -305,13 +305,13 @@ class Tests_URL extends WP_UnitTestCase { * @ticket 30287 */ public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() { - $u = $this->factory->user->create( array( 'role' => 'author' ) ); + $u = self::$factory->user->create( array( 'role' => 'author' ) ); $old_uid = get_current_user_id(); wp_set_current_user( $u ); $now = time(); - $p1 = $this->factory->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); - $p2 = $this->factory->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); + $p1 = self::$factory->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); + $p2 = self::$factory->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); if ( ! isset( $GLOBALS['post'] ) ) { $GLOBALS['post'] = null; @@ -331,14 +331,14 @@ class Tests_URL extends WP_UnitTestCase { * @ticket 30287 */ public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() { - $u1 = $this->factory->user->create( array( 'role' => 'author' ) ); - $u2 = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $u1 = self::$factory->user->create( array( 'role' => 'author' ) ); + $u2 = self::$factory->user->create( array( 'role' => 'administrator' ) ); $old_uid = get_current_user_id(); wp_set_current_user( $u2 ); $now = time(); - $p1 = $this->factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); - $p2 = $this->factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); + $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); + $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); if ( ! isset( $GLOBALS['post'] ) ) { $GLOBALS['post'] = null; @@ -358,15 +358,15 @@ class Tests_URL extends WP_UnitTestCase { * @ticket 30287 */ public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() { - $u1 = $this->factory->user->create( array( 'role' => 'author' ) ); - $u2 = $this->factory->user->create( array( 'role' => 'author' ) ); + $u1 = self::$factory->user->create( array( 'role' => 'author' ) ); + $u2 = self::$factory->user->create( array( 'role' => 'author' ) ); $old_uid = get_current_user_id(); wp_set_current_user( $u2 ); $now = time(); - $p1 = $this->factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) ); - $p2 = $this->factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); - $p3 = $this->factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); + $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) ); + $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); + $p3 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); if ( ! isset( $GLOBALS['post'] ) ) { $GLOBALS['post'] = null; diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index f9b0e63dcf..07bbabddfa 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -43,7 +43,7 @@ class Tests_User extends WP_UnitTestCase { // add one of each user role $nusers = array(); foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) { - $id = self::$static_factory->user->create( array( 'role' => $role ) ); + $id = self::$factory->user->create( array( 'role' => $role ) ); $nusers[ $id ] = $id; } @@ -244,7 +244,7 @@ class Tests_User extends WP_UnitTestCase { ); foreach ( $roles as $role => $level ) { - $user_id = self::$static_factory->user->create( array( 'role' => $role ) ); + $user_id = self::$factory->user->create( array( 'role' => $role ) ); $user = new WP_User( $user_id ); $this->assertTrue( isset( $user->user_level ) ); @@ -292,7 +292,7 @@ class Tests_User extends WP_UnitTestCase { } function test_get() { - $user_id = self::$static_factory->user->create( array( + $user_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'test_wp_user_get', 'user_pass' => 'password', @@ -310,7 +310,7 @@ class Tests_User extends WP_UnitTestCase { } function test_has_prop() { - $user_id = self::$static_factory->user->create( array( + $user_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'test_wp_user_has_prop', 'user_pass' => 'password', @@ -327,7 +327,7 @@ class Tests_User extends WP_UnitTestCase { } function test_update_user() { - $user_id = self::$static_factory->user->create( array( + $user_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'test_wp_update_user', 'user_pass' => 'password', @@ -383,7 +383,7 @@ class Tests_User extends WP_UnitTestCase { function test_global_userdata() { global $userdata, $wpdb; - $user_id = self::$static_factory->user->create( array( 'role' => 'subscriber' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); wp_set_current_user( $user_id ); $this->assertNotEmpty( $userdata ); @@ -497,11 +497,11 @@ class Tests_User extends WP_UnitTestCase { * @ticket 21431 */ function test_count_many_users_posts() { - $user_id_a = self::$static_factory->user->create( array( 'role' => 'author' ) ); - $user_id_b = self::$static_factory->user->create( array( 'role' => 'author' ) ); - $post_id_a = $this->factory->post->create( array( 'post_author' => $user_id_a ) ); - $post_id_b = $this->factory->post->create( array( 'post_author' => $user_id_b ) ); - $post_id_c = $this->factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) ); + $user_id_a = self::$factory->user->create( array( 'role' => 'author' ) ); + $user_id_b = self::$factory->user->create( array( 'role' => 'author' ) ); + $post_id_a = self::$factory->post->create( array( 'post_author' => $user_id_a ) ); + $post_id_b = self::$factory->post->create( array( 'post_author' => $user_id_b ) ); + $post_id_c = self::$factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) ); wp_set_current_user( $user_id_a ); $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', false ); @@ -771,7 +771,7 @@ class Tests_User extends WP_UnitTestCase { * @ticket 33793 */ public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() { - $u1 = self::$static_factory->user->create( array( + $u1 = self::$factory->user->create( array( 'user_nicename' => str_repeat( 'a', 50 ), ) ); @@ -792,7 +792,7 @@ class Tests_User extends WP_UnitTestCase { * @ticket 33793 */ public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() { - $users = self::$static_factory->user->create_many( 4, array( + $users = self::$factory->user->create_many( 4, array( 'user_nicename' => str_repeat( 'a', 50 ), ) ); @@ -876,7 +876,7 @@ class Tests_User extends WP_UnitTestCase { */ function test_email_case() { // Create a test user with a lower-case email address. - $user_id = self::$static_factory->user->create( array( + $user_id = self::$factory->user->create( array( 'user_email' => 'test@test.com', ) ); @@ -895,7 +895,7 @@ class Tests_User extends WP_UnitTestCase { */ function test_email_change() { // Create a test user. - $user_id = self::$static_factory->user->create( array( + $user_id = self::$factory->user->create( array( 'user_email' => 'test@test.com', ) ); @@ -983,7 +983,7 @@ class Tests_User extends WP_UnitTestCase { * @expectedDeprecated wp_new_user_notification */ function test_wp_new_user_notification_old_signature_throws_deprecated_warning() { - $user = self::$static_factory->user->create( array( + $user = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'test_wp_new_user_notification', 'user_pass' => 'password', diff --git a/tests/phpunit/tests/user/author.php b/tests/phpunit/tests/user/author.php index 8b83ada7a1..d236d2a157 100644 --- a/tests/phpunit/tests/user/author.php +++ b/tests/phpunit/tests/user/author.php @@ -15,7 +15,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( + $this->author_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'test_author', 'description' => 'test_author', @@ -31,7 +31,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase { ); // insert a post and make sure the ID is ok - $this->post_id = $this->factory->post->create( $post ); + $this->post_id = self::$factory->post->create( $post ); setup_postdata( get_post( $this->post_id ) ); } @@ -90,7 +90,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase { function test_get_the_author_posts_with_custom_post_type() { register_post_type( 'wptests_pt' ); - $cpt_ids = $this->factory->post->create_many( 2, array( + $cpt_ids = self::$factory->post->create_many( 2, array( 'post_author' => $this->author_id, 'post_type' => 'wptests_pt', ) ); @@ -105,7 +105,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase { * @ticket 30355 */ public function test_get_the_author_posts_link_no_permalinks() { - $author = $this->factory->user->create_and_get( array( + $author = self::$factory->user->create_and_get( array( 'display_name' => 'Foo', 'user_nicename' => 'bar' ) ); @@ -129,7 +129,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase { public function test_get_the_author_posts_link_with_permalinks() { $this->set_permalink_structure( '/%postname%/' ); - $author = $this->factory->user->create_and_get( array( + $author = self::$factory->user->create_and_get( array( 'display_name' => 'Foo', 'user_nicename' => 'bar' ) ); diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index 2f58902315..0d1960b6c3 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -222,11 +222,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // test the default roles and caps function test_all_roles_and_caps() { $users = array( - 'administrator' => $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ), - 'editor' => $this->factory->user->create_and_get( array( 'role' => 'editor' ) ), - 'author' => $this->factory->user->create_and_get( array( 'role' => 'author' ) ), - 'contributor' => $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ), - 'subscriber' => $this->factory->user->create_and_get( array( 'role' => 'subscriber' ) ), + 'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ), + 'editor' => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ), + 'author' => self::$factory->user->create_and_get( array( 'role' => 'author' ) ), + 'contributor' => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ), + 'subscriber' => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ), ); $caps = $this->getCapsAndRoles(); @@ -258,11 +258,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // special case for the link manager function test_link_manager_caps() { $users = array( - 'administrator' => $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ), - 'editor' => $this->factory->user->create_and_get( array( 'role' => 'editor' ) ), - 'author' => $this->factory->user->create_and_get( array( 'role' => 'author' ) ), - 'contributor' => $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ), - 'subscriber' => $this->factory->user->create_and_get( array( 'role' => 'subscriber' ) ), + 'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ), + 'editor' => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ), + 'author' => self::$factory->user->create_and_get( array( 'role' => 'author' ) ), + 'contributor' => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ), + 'subscriber' => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ), ); $caps = array( 'manage_links' => array( 'administrator', 'editor' ), @@ -305,7 +305,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } $caps = $this->getCapsAndRoles(); - $user = $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ); + $user = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ); grant_super_admin( $user->ID ); $this->assertTrue( is_super_admin( $user->ID ) ); @@ -321,7 +321,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // a role that doesn't exist function test_bogus_role() { - $user = $this->factory->user->create_and_get( array( 'role' => 'invalid_role' ) ); + $user = self::$factory->user->create_and_get( array( 'role' => 'invalid_role' ) ); // make sure the user is valid $this->assertTrue( $user->exists(), "User does not exist" ); @@ -339,7 +339,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // a user with multiple roles function test_user_subscriber_contributor() { - $user = $this->factory->user->create_and_get( array( 'role' => 'subscriber' ) ); + $user = self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ); // make sure the user is valid $this->assertTrue( $user->exists(), "User does not exist" ); @@ -372,7 +372,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->_flush_roles(); $this->assertTrue( $wp_roles->is_role( $role_name ) ); - $user = $this->factory->user->create_and_get( array( 'role' => $role_name ) ); + $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) ); // make sure the user is valid $this->assertTrue( $user->exists(), "User does not exist" ); @@ -409,7 +409,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->_flush_roles(); $this->assertTrue( $wp_roles->is_role( $role_name ) ); - $user = $this->factory->user->create_and_get( array( 'role' => $role_name ) ); + $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) ); // make sure the user is valid $this->assertTrue( $user->exists(), "User does not exist" ); @@ -446,7 +446,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $wp_roles->is_role($role_name) ); // assign a user to that role - $id = $this->factory->user->create( array( 'role' => $role_name ) ); + $id = self::$factory->user->create( array( 'role' => $role_name ) ); // now add a cap to the role $wp_roles->add_cap($role_name, 'sweep_floor'); @@ -484,7 +484,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $wp_roles->is_role($role_name) ); // assign a user to that role - $id = $this->factory->user->create( array( 'role' => $role_name ) ); + $id = self::$factory->user->create( array( 'role' => $role_name ) ); // now remove a cap from the role $wp_roles->remove_cap($role_name, 'polish_doorknobs'); @@ -513,8 +513,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // add an extra capability to a user // there are two contributors - $id_1 = $this->factory->user->create( array( 'role' => 'contributor' ) ); - $id_2 = $this->factory->user->create( array( 'role' => 'contributor' ) ); + $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) ); + $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) ); // user 1 has an extra capability $user_1 = new WP_User($id_1); @@ -550,8 +550,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // add an extra capability to a user then remove it // there are two contributors - $id_1 = $this->factory->user->create( array( 'role' => 'contributor' ) ); - $id_2 = $this->factory->user->create( array( 'role' => 'contributor' ) ); + $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) ); + $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) ); // user 1 has an extra capability $user_1 = new WP_User($id_1); @@ -581,7 +581,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // make sure the user_level is correctly set and changed with the user's role // user starts as an author - $id = $this->factory->user->create( array( 'role' => 'author' ) ); + $id = self::$factory->user->create( array( 'role' => 'author' ) ); $user = new WP_User($id); $this->assertTrue($user->exists(), "Problem getting user $id"); @@ -604,7 +604,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { function test_user_remove_all_caps() { // user starts as an author - $id = $this->factory->user->create( array( 'role' => 'author' ) ); + $id = self::$factory->user->create( array( 'role' => 'author' ) ); $user = new WP_User($id); $this->assertTrue($user->exists(), "Problem getting user $id"); @@ -646,19 +646,19 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // simple tests for some common meta capabilities // Make our author - $author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); + $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); // make a post - $post = $this->factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) ); + $post = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) ); // the author of the post $this->assertTrue($author->exists(), "Problem getting user $author->ID"); // add some other users - $admin = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); - $author_2 = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); - $editor = new WP_User( $this->factory->user->create( array( 'role' => 'editor' ) ) ); - $contributor = new WP_User( $this->factory->user->create( array( 'role' => 'contributor' ) ) ); + $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); + $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); + $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); + $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); // administrators, editors and the post owner can edit it $this->assertTrue($admin->has_cap('edit_post', $post)); @@ -732,11 +732,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { */ function test_authorless_post( $status ) { // Make a post without an author - $post = $this->factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) ); + $post = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) ); // Add an editor and contributor - $editor = $this->factory->user->create_and_get( array( 'role' => 'editor' ) ); - $contributor = $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ); + $editor = self::$factory->user->create_and_get( array( 'role' => 'editor' ) ); + $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ); // editor can edit, view, and trash $this->assertTrue( $editor->has_cap( 'edit_post', $post ) ); @@ -753,11 +753,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @ticket 16714 */ function test_create_posts_caps() { - $author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); - $admin = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); - $author_2 = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); - $editor = new WP_User( $this->factory->user->create( array( 'role' => 'editor' ) ) ); - $contributor = new WP_User( $this->factory->user->create( array( 'role' => 'contributor' ) ) ); + $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); + $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); + $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); + $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); + $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); // create_posts isn't a real cap. $this->assertFalse($admin->has_cap('create_posts')); @@ -818,19 +818,19 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // simple tests for some common meta capabilities // Make our author - $author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); + $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); // make a page - $page = $this->factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) ); + $page = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) ); // the author of the page $this->assertTrue($author->exists(), "Problem getting user " . $author->ID); // add some other users - $admin = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); - $author_2 = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); - $editor = new WP_User( $this->factory->user->create( array( 'role' => 'editor' ) ) ); - $contributor = new WP_User( $this->factory->user->create( array( 'role' => 'contributor' ) ) ); + $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); + $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); + $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); + $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); // administrators, editors and the post owner can edit it $this->assertTrue($admin->has_cap('edit_page', $page)); @@ -853,7 +853,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @ticket 21786 */ function test_negative_caps() { - $author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) ); + $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); $author->add_cap( 'foo', false ); $this->assertTrue ( isset( $author->caps['foo'] ) ); $author->remove_cap( 'foo' ); @@ -864,7 +864,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @ticket 18932 */ function test_set_role_same_role() { - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $caps = $user->caps; $this->assertNotEmpty( $user->caps ); $user->set_role( 'administrator' ); @@ -875,7 +875,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { function test_current_user_can_for_blog() { global $wpdb; - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $old_uid = get_current_user_id(); wp_set_current_user( $user->ID ); @@ -890,7 +890,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); $wpdb->suppress_errors( $suppress ); - $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) ); + $blog_id = self::$factory->blog->create( array( 'user_id' => $user->ID ) ); $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) ); $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) ); @@ -904,7 +904,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } $orig_blog_id = get_current_blog_id(); - $blog_id = $this->factory->blog->create(); + $blog_id = self::$factory->blog->create(); $this->_nullify_current_user(); @@ -932,7 +932,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { * @ticket 28374 */ function test_current_user_edit_caps() { - $user = new WP_User( $this->factory->user->create( array( 'role' => 'contributor' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); wp_set_current_user( $user->ID ); $user->add_cap( 'publish_posts' ); @@ -945,10 +945,10 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } function test_subscriber_cant_edit_posts() { - $user = new WP_User( $this->factory->user->create( array( 'role' => 'subscriber' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); wp_set_current_user( $user->ID ); - $post = $this->factory->post->create( array( 'post_author' => 1 ) ); + $post = self::$factory->post->create( array( 'post_author' => 1 ) ); $this->assertFalse( current_user_can( 'edit_post', $post ) ); $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) ); @@ -960,8 +960,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { return; } - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); - $other_user = new WP_User( $this->factory->user->create( array( 'role' => 'subscriber' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); + $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); wp_set_current_user( $user->ID ); @@ -974,7 +974,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { return; } - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); wp_set_current_user( $user->ID ); @@ -987,9 +987,9 @@ class Tests_User_Capabilities extends WP_UnitTestCase { return; } - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $user->add_cap( 'manage_network_users' ); - $other_user = new WP_User( $this->factory->user->create( array( 'role' => 'subscriber' ) ) ); + $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); wp_set_current_user( $user->ID ); @@ -1002,9 +1002,9 @@ class Tests_User_Capabilities extends WP_UnitTestCase { return; } - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); $user->add_cap( 'manage_network_users' ); - $super_admin = new WP_User( $this->factory->user->create( array( 'role' => 'subscriber' ) ) ); + $super_admin = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); grant_super_admin( $super_admin->ID ); wp_set_current_user( $user->ID ); @@ -1017,11 +1017,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { */ function test_require_edit_others_posts_if_post_type_doesnt_exist() { register_post_type( 'existed' ); - $post_id = $this->factory->post->create( array( 'post_type' => 'existed' ) ); + $post_id = self::$factory->post->create( array( 'post_type' => 'existed' ) ); _unregister_post_type( 'existed' ); - $subscriber_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + $subscriber_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); + $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->setExpectedIncorrectUsage( 'map_meta_cap' ); foreach ( array( 'delete_post', 'edit_post', 'read_post', 'publish_post' ) as $cap ) { @@ -1046,10 +1046,10 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $cpt = get_post_type_object( 'page_capability' ); - $admin = $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ); - $editor = $this->factory->user->create_and_get( array( 'role' => 'editor' ) ); - $author = $this->factory->user->create_and_get( array( 'role' => 'author' ) ); - $contributor = $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ); + $admin = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ); + $editor = self::$factory->user->create_and_get( array( 'role' => 'editor' ) ); + $author = self::$factory->user->create_and_get( array( 'role' => 'author' ) ); + $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ); $this->assertEquals( 'edit_pages', $cpt->cap->edit_posts ); $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) ); @@ -1057,7 +1057,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertFalse( user_can( $author->ID, $cpt->cap->edit_posts ) ); $this->assertFalse( user_can( $contributor->ID, $cpt->cap->edit_posts ) ); - $admin_post = $this->factory->post->create_and_get( array( + $admin_post = self::$factory->post->create_and_get( array( 'post_author' => $admin->ID, 'post_type' => 'page_capability', ) ); @@ -1067,7 +1067,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertFalse( user_can( $author->ID, 'edit_post', $admin_post->ID ) ); $this->assertFalse( user_can( $contributor->ID, 'edit_post', $admin_post->ID ) ); - $author_post = $this->factory->post->create_and_get( array( + $author_post = self::$factory->post->create_and_get( array( 'post_author' => $author->ID, 'post_type' => 'page_capability', ) ); diff --git a/tests/phpunit/tests/user/countUsers.php b/tests/phpunit/tests/user/countUsers.php index 6d783debb8..4a758f0c45 100644 --- a/tests/phpunit/tests/user/countUsers.php +++ b/tests/phpunit/tests/user/countUsers.php @@ -17,25 +17,25 @@ class Tests_User_CountUsers extends WP_UnitTestCase { } // Setup users - $admin = $this->factory->user->create( array( + $admin = self::$factory->user->create( array( 'role' => 'administrator', ) ); - $editor = $this->factory->user->create( array( + $editor = self::$factory->user->create( array( 'role' => 'editor', ) ); - $author = $this->factory->user->create( array( + $author = self::$factory->user->create( array( 'role' => 'author', ) ); - $contributor = $this->factory->user->create( array( + $contributor = self::$factory->user->create( array( 'role' => 'contributor', ) ); - $subscriber = $this->factory->user->create( array( + $subscriber = self::$factory->user->create( array( 'role' => 'subscriber', ) ); - $none = $this->factory->user->create( array( + $none = self::$factory->user->create( array( 'role' => '', ) ); - $nobody = $this->factory->user->create( array( + $nobody = self::$factory->user->create( array( 'role' => '', ) ); @@ -67,33 +67,33 @@ class Tests_User_CountUsers extends WP_UnitTestCase { } // Setup users - $admin = $this->factory->user->create( array( + $admin = self::$factory->user->create( array( 'role' => 'administrator', ) ); - $editor = $this->factory->user->create( array( + $editor = self::$factory->user->create( array( 'role' => 'editor', ) ); - $author = $this->factory->user->create( array( + $author = self::$factory->user->create( array( 'role' => 'author', ) ); - $contributor = $this->factory->user->create( array( + $contributor = self::$factory->user->create( array( 'role' => 'contributor', ) ); - $subscriber = $this->factory->user->create( array( + $subscriber = self::$factory->user->create( array( 'role' => 'subscriber', ) ); - $none = $this->factory->user->create( array( + $none = self::$factory->user->create( array( 'role' => '', ) ); - $nobody = $this->factory->user->create( array( + $nobody = self::$factory->user->create( array( 'role' => '', ) ); // Setup blogs - $blog_1 = (int) $this->factory->blog->create( array( + $blog_1 = (int) self::$factory->blog->create( array( 'user_id' => $editor, ) ); - $blog_2 = (int) $this->factory->blog->create( array( + $blog_2 = (int) self::$factory->blog->create( array( 'user_id' => $author, ) ); diff --git a/tests/phpunit/tests/user/dateQuery.php b/tests/phpunit/tests/user/dateQuery.php index 3add9507c3..448bd59d17 100644 --- a/tests/phpunit/tests/user/dateQuery.php +++ b/tests/phpunit/tests/user/dateQuery.php @@ -9,10 +9,10 @@ class Tests_User_DateQuery extends WP_UnitTestCase { * @ticket 27283 */ public function test_user_registered() { - $u1 = $this->factory->user->create( array( + $u1 = self::$factory->user->create( array( 'user_registered' => '2012-02-14 05:05:05', ) ); - $u2 = $this->factory->user->create( array( + $u2 = self::$factory->user->create( array( 'user_registered' => '2013-02-14 05:05:05', ) ); @@ -31,13 +31,13 @@ class Tests_User_DateQuery extends WP_UnitTestCase { * @ticket 27283 */ public function test_user_registered_relation_or() { - $u1 = $this->factory->user->create( array( + $u1 = self::$factory->user->create( array( 'user_registered' => '2012-02-14 05:05:05', ) ); - $u2 = $this->factory->user->create( array( + $u2 = self::$factory->user->create( array( 'user_registered' => '2013-02-14 05:05:05', ) ); - $u3 = $this->factory->user->create( array( + $u3 = self::$factory->user->create( array( 'user_registered' => '2014-02-14 05:05:05', ) ); diff --git a/tests/phpunit/tests/user/listAuthors.php b/tests/phpunit/tests/user/listAuthors.php index 8b8d5c1b1e..11432ac307 100644 --- a/tests/phpunit/tests/user/listAuthors.php +++ b/tests/phpunit/tests/user/listAuthors.php @@ -71,7 +71,7 @@ class Tests_User_ListAuthors extends WP_UnitTestCase { } function test_wp_list_authors_exclude_admin() { - $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) ); + self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) ); $expected['exclude_admin'] = '
  • admin
  • bob
  • paul
  • zack
  • '; $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) ); } diff --git a/tests/phpunit/tests/user/mapMetaCap.php b/tests/phpunit/tests/user/mapMetaCap.php index 09e61e2811..4a65003b06 100644 --- a/tests/phpunit/tests/user/mapMetaCap.php +++ b/tests/phpunit/tests/user/mapMetaCap.php @@ -12,8 +12,8 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->user_ids = array(); - $this->user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $this->author_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); if ( isset( $GLOBALS['super_admins'] ) ) $this->super_admins = $GLOBALS['super_admins']; @@ -248,8 +248,8 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { * @ticket 27020 */ function test_authorless_posts_capabilties() { - $post_id = $this->factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) ); - $editor = $this->factory->user->create( array( 'role' => 'editor' ) ); + $post_id = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) ); + $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); $this->assertEquals( array( 'edit_others_posts', 'edit_published_posts' ), map_meta_cap( 'edit_post', $editor, $post_id ) ); $this->assertEquals( array( 'delete_others_posts', 'delete_published_posts' ), map_meta_cap( 'delete_post', $editor, $post_id ) ); diff --git a/tests/phpunit/tests/user/multisite.php b/tests/phpunit/tests/user/multisite.php index 35b3738fe4..2a36d36018 100644 --- a/tests/phpunit/tests/user/multisite.php +++ b/tests/phpunit/tests/user/multisite.php @@ -25,10 +25,10 @@ class Tests_Multisite_User extends WP_UnitTestCase { } function test_remove_user_from_blog() { - $user1 = $this->factory->user->create_and_get(); - $user2 = $this->factory->user->create_and_get(); + $user1 = self::$factory->user->create_and_get(); + $user2 = self::$factory->user->create_and_get(); - $post_id = $this->factory->post->create( array( 'post_author' => $user1->ID ) ); + $post_id = self::$factory->post->create( array( 'post_author' => $user1->ID ) ); remove_user_from_blog( $user1->ID, 1, $user2->ID ); @@ -42,10 +42,10 @@ class Tests_Multisite_User extends WP_UnitTestCase { * Test the returned data from get_blogs_of_user() */ function test_get_blogs_of_user() { - $user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); // Maintain a list of 6 total sites and include the primary network site. - $blog_ids = $this->factory->blog->create_many( 5, array( 'user_id' => $user1_id ) ); + $blog_ids = self::$factory->blog->create_many( 5, array( 'user_id' => $user1_id ) ); $blog_ids = array_merge( array( 1 ), $blog_ids ); // All sites are new and not marked as spam, archived, or deleted. @@ -114,7 +114,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { function test_is_blog_user() { global $wpdb; - $user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); $old_current = get_current_user_id(); wp_set_current_user( $user1_id ); @@ -124,7 +124,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { $blog_ids = array(); - $blog_ids = $this->factory->blog->create_many( 5 ); + $blog_ids = self::$factory->blog->create_many( 5 ); foreach ( $blog_ids as $blog_id ) { $this->assertInternalType( 'int', $blog_id ); $this->assertTrue( is_blog_user( $blog_id ) ); @@ -138,8 +138,8 @@ class Tests_Multisite_User extends WP_UnitTestCase { function test_is_user_member_of_blog() { global $wpdb; - $user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $user2_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); + $user2_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); $old_current = get_current_user_id(); @@ -156,7 +156,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { $this->assertTrue( is_user_member_of_blog( $user1_id ) ); $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) ); - $blog_ids = $this->factory->blog->create_many( 5 ); + $blog_ids = self::$factory->blog->create_many( 5 ); foreach ( $blog_ids as $blog_id ) { $this->assertInternalType( 'int', $blog_id ); @@ -197,13 +197,13 @@ class Tests_Multisite_User extends WP_UnitTestCase { * @ticket 23192 */ function test_is_user_spammy() { - $user_id = $this->factory->user->create( array( + $user_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => 'testuser1', ) ); $spam_username = (string) $user_id; - $spam_user_id = $this->factory->user->create( array( + $spam_user_id = self::$factory->user->create( array( 'role' => 'author', 'user_login' => $spam_username, ) ); @@ -219,9 +219,9 @@ class Tests_Multisite_User extends WP_UnitTestCase { function test_user_member_of_blog() { global $wp_rewrite; - $this->factory->blog->create(); - $user_id = $this->factory->user->create(); - $this->factory->blog->create( array( 'user_id' => $user_id ) ); + self::$factory->blog->create(); + $user_id = self::$factory->user->create(); + self::$factory->blog->create( array( 'user_id' => $user_id ) ); $blogs = get_blogs_of_user( $user_id ); $this->assertCount( 2, $blogs ); @@ -261,7 +261,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { unset( $GLOBALS['super_admins'] ); } - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); grant_super_admin( $user_id ); revoke_super_admin( $user_id ); @@ -278,7 +278,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { unset( $GLOBALS['super_admins'] ); } - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); grant_super_admin( $user_id ); revoke_super_admin( $user_id ); wpmu_delete_user( $user_id ); @@ -297,7 +297,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { unset( $GLOBALS['super_admins'] ); } - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); grant_super_admin( $user_id ); $this->assertFalse( wpmu_delete_user( $user_id ) ); @@ -316,7 +316,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { unset( $GLOBALS['super_admins'] ); } - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); $this->assertFalse( is_super_admin( $user_id ) ); $this->assertFalse( revoke_super_admin( $user_id ) ); @@ -329,7 +329,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { $this->assertFalse( isset( $GLOBALS['super_admins'] ) ); // Try with two users. - $second_user = $this->factory->user->create(); + $second_user = self::$factory->user->create(); $this->assertTrue( grant_super_admin( $user_id ) ); $this->assertTrue( grant_super_admin( $second_user ) ); $this->assertTrue( is_super_admin( $second_user ) ); @@ -343,7 +343,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { } public function test_numeric_string_user_id() { - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $u_string = (string) $u; $this->assertTrue( wpmu_delete_user( $u_string ) ); @@ -361,7 +361,7 @@ class Tests_Multisite_User extends WP_UnitTestCase { * @ticket 33800 */ public function test_should_return_false_for_object_user_id() { - $u_obj = $this->factory->user->create_and_get(); + $u_obj = self::$factory->user->create_and_get(); $this->assertFalse( wpmu_delete_user( $u_obj ) ); $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); } diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index 9d063bdc04..0287975adc 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -245,13 +245,13 @@ class Tests_User_Query extends WP_UnitTestCase { * @ticket 31265 */ public function test_orderby_clause_key_as_secondary_sort() { - $u1 = self::$static_factory->user->create( array( + $u1 = self::$factory->user->create( array( 'user_registered' => '2015-01-28 03:00:00', ) ); - $u2 = self::$static_factory->user->create( array( + $u2 = self::$factory->user->create( array( 'user_registered' => '2015-01-28 05:00:00', ) ); - $u3 = self::$static_factory->user->create( array( + $u3 = self::$factory->user->create( array( 'user_registered' => '2015-01-28 03:00:00', ) ); @@ -598,7 +598,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); } - $b = $this->factory->blog->create(); + $b = self::$factory->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'author' ); @@ -624,7 +624,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); } - $b = $this->factory->blog->create(); + $b = self::$factory->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'author' ); $query = new WP_User_Query( array( @@ -649,7 +649,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); } - $b = $this->factory->blog->create(); + $b = self::$factory->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); add_user_to_blog( $b, self::$author_ids[1], 'author' ); @@ -675,7 +675,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); } - $b = $this->factory->blog->create(); + $b = self::$factory->blog->create(); add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); add_user_to_blog( $b, self::$author_ids[1], 'author' ); @@ -707,8 +707,8 @@ class Tests_User_Query extends WP_UnitTestCase { register_post_type( 'wptests_pt_public', array( 'public' => true ) ); register_post_type( 'wptests_pt_private', array( 'public' => false ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); $q = new WP_User_Query( array( 'has_published_posts' => true, @@ -727,9 +727,9 @@ class Tests_User_Query extends WP_UnitTestCase { register_post_type( 'wptests_pt_public', array( 'public' => true ) ); register_post_type( 'wptests_pt_private', array( 'public' => false ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); $q = new WP_User_Query( array( 'has_published_posts' => array( 'wptests_pt_private', 'post' ), @@ -748,9 +748,9 @@ class Tests_User_Query extends WP_UnitTestCase { register_post_type( 'wptests_pt_public', array( 'public' => true ) ); register_post_type( 'wptests_pt_private', array( 'public' => false ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); $q = new WP_User_Query( array( 'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ), @@ -770,7 +770,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); } - $blogs = $this->factory->blog->create_many( 2 ); + $blogs = self::$factory->blog->create_many( 2 ); add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' ); add_user_to_blog( $blogs[0], self::$author_ids[1], 'author' ); @@ -778,11 +778,11 @@ class Tests_User_Query extends WP_UnitTestCase { add_user_to_blog( $blogs[1], self::$author_ids[1], 'author' ); switch_to_blog( $blogs[0] ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) ); restore_current_blog(); switch_to_blog( $blogs[1] ); - $this->factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) ); + self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) ); restore_current_blog(); $q = new WP_User_Query( array( @@ -931,7 +931,7 @@ class Tests_User_Query extends WP_UnitTestCase { * @ticket 22212 */ public function test_get_single_role_by_string_which_is_similar() { - $another_editor = $this->factory->user->create( array( + $another_editor = self::$factory->user->create( array( 'role' => 'another-editor', ) ); @@ -1148,7 +1148,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); } - $sites = self::$static_factory->blog->create_many( 2 ); + $sites = self::$factory->blog->create_many( 2 ); add_user_to_blog( $sites[0], self::$author_ids[0], 'author' ); add_user_to_blog( $sites[1], self::$author_ids[1], 'author' ); diff --git a/tests/phpunit/tests/user/session.php b/tests/phpunit/tests/user/session.php index 565676f56f..ee29cce4b7 100644 --- a/tests/phpunit/tests/user/session.php +++ b/tests/phpunit/tests/user/session.php @@ -10,7 +10,7 @@ class Tests_User_Session extends WP_UnitTestCase { function setUp() { parent::setUp(); remove_all_filters( 'session_token_manager' ); - $user_id = $this->factory->user->create(); + $user_id = self::$factory->user->create(); $this->manager = WP_Session_Tokens::get_instance( $user_id ); $this->assertInstanceOf( 'WP_Session_Tokens', $this->manager ); $this->assertInstanceOf( 'WP_User_Meta_Session_Tokens', $this->manager ); diff --git a/tests/phpunit/tests/user/slashes.php b/tests/phpunit/tests/user/slashes.php index 2decb33f83..9b44484028 100644 --- a/tests/phpunit/tests/user/slashes.php +++ b/tests/phpunit/tests/user/slashes.php @@ -8,7 +8,7 @@ class Tests_User_Slashes extends WP_UnitTestCase { function setUp() { parent::setUp(); - $this->author_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); + $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); $this->old_current_user = get_current_user_id(); wp_set_current_user( $this->author_id ); @@ -83,7 +83,7 @@ class Tests_User_Slashes extends WP_UnitTestCase { * */ function test_edit_user() { - $id = $this->factory->user->create(); + $id = self::$factory->user->create(); $_POST = $_GET = $_REQUEST = array(); $_POST['role'] = 'subscriber'; @@ -173,7 +173,7 @@ class Tests_User_Slashes extends WP_UnitTestCase { * */ function test_wp_update_user() { - $id = $this->factory->user->create(); + $id = self::$factory->user->create(); $id = wp_update_user(array( 'ID' => $id, 'role' => 'subscriber', diff --git a/tests/phpunit/tests/user/updateUserCaches.php b/tests/phpunit/tests/user/updateUserCaches.php index f4b0856834..7d29cec38f 100644 --- a/tests/phpunit/tests/user/updateUserCaches.php +++ b/tests/phpunit/tests/user/updateUserCaches.php @@ -7,7 +7,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { public function test_should_store_entire_database_row_in_users_bucket() { global $wpdb; - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) ); update_user_caches( $raw_userdata ); @@ -57,7 +57,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object() { global $wpdb; - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) ); $user_object = new WP_User( $u ); diff --git a/tests/phpunit/tests/user/wpDeleteUser.php b/tests/phpunit/tests/user/wpDeleteUser.php index 0589f39635..6c05a2ae48 100644 --- a/tests/phpunit/tests/user/wpDeleteUser.php +++ b/tests/phpunit/tests/user/wpDeleteUser.php @@ -14,7 +14,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { // Logged out users don't have blogs. $this->assertEquals( array(), get_blogs_of_user( 0 ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); $blogs = get_blogs_of_user( $user_id ); $this->assertEquals( array( 1 ), array_keys( $blogs ) ); @@ -34,7 +34,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { function test_is_user_member_of_blog() { $old_current = get_current_user_id(); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); wp_set_current_user( $user_id ); $this->assertTrue( is_user_member_of_blog() ); @@ -54,7 +54,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { } function test_delete_user() { - $user_id = $this->factory->user->create( array( 'role' => 'author' ) ); + $user_id = self::$factory->user->create( array( 'role' => 'author' ) ); $user = new WP_User( $user_id ); $post = array( @@ -111,9 +111,9 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { * @ticket 20447 */ function test_wp_delete_user_reassignment_clears_post_caches() { - $user_id = $this->factory->user->create(); - $reassign = $this->factory->user->create(); - $post_id = $this->factory->post->create( array( 'post_author' => $user_id ) ); + $user_id = self::$factory->user->create(); + $reassign = self::$factory->user->create(); + $post_id = self::$factory->post->create( array( 'post_author' => $user_id ) ); get_post( $post_id ); // Ensure this post is in the cache. @@ -128,7 +128,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' ); } - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $u_string = (string) $u; $this->assertTrue( wp_delete_user( $u_string ) ); @@ -150,7 +150,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' ); } - $u_obj = $this->factory->user->create_and_get(); + $u_obj = self::$factory->user->create_and_get(); $this->assertFalse( wp_delete_user( $u_obj ) ); $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); } diff --git a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php index ff01fabc67..d9cc898309 100644 --- a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php +++ b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php @@ -15,16 +15,16 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { } // Setup users - $admin = $this->factory->user->create( array( + $admin = self::$factory->user->create( array( 'role' => 'administrator', ) ); - $editor = $this->factory->user->create( array( + $editor = self::$factory->user->create( array( 'role' => 'editor', ) ); - $nobody = $this->factory->user->create( array( + $nobody = self::$factory->user->create( array( 'role' => '', ) ); - $nobody_else = $this->factory->user->create( array( + $nobody_else = self::$factory->user->create( array( 'role' => '', ) ); @@ -49,18 +49,18 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { } // Setup users - $admin = $this->factory->user->create( array( + $admin = self::$factory->user->create( array( 'role' => 'administrator', ) ); - $editor = $this->factory->user->create( array( + $editor = self::$factory->user->create( array( 'role' => 'editor', ) ); - $nobody = $this->factory->user->create( array( + $nobody = self::$factory->user->create( array( 'role' => '', ) ); // Setup blogs - $blog_1 = (int) $this->factory->blog->create( array( + $blog_1 = (int) self::$factory->blog->create( array( 'user_id' => $editor, ) ); diff --git a/tests/phpunit/tests/user/wpSetCurrentUser.php b/tests/phpunit/tests/user/wpSetCurrentUser.php index b3c8fce918..5b7c0f097b 100644 --- a/tests/phpunit/tests/user/wpSetCurrentUser.php +++ b/tests/phpunit/tests/user/wpSetCurrentUser.php @@ -5,7 +5,7 @@ */ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { public function test_set_by_id() { - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $user = wp_set_current_user( $u ); @@ -15,7 +15,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { } public function test_name_should_be_ignored_if_id_is_not_null() { - $u = $this->factory->user->create(); + $u = self::$factory->user->create(); $user = wp_set_current_user( $u, 'foo' ); @@ -25,11 +25,11 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { } public function test_should_set_by_name_if_id_is_null_and_current_user_is_nonempty() { - $u1 = $this->factory->user->create(); + $u1 = self::$factory->user->create(); wp_set_current_user( $u1 ); $this->assertSame( $u1, get_current_user_id() ); - $u2 = $this->factory->user->create( array( + $u2 = self::$factory->user->create( array( 'user_login' => 'foo', ) ); @@ -49,7 +49,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { wp_set_current_user( 0 ); $this->assertSame( 0, get_current_user_id() ); - $u = $this->factory->user->create( array( + $u = self::$factory->user->create( array( 'user_login' => 'foo', ) ); diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 38ac3b68bd..35cadc4709 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -438,7 +438,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertEmpty( $wp_customize ); $this->assertFalse( $widget->is_preview() ); - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); + wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager(); $wp_customize->start_previewing_theme(); @@ -618,7 +618,7 @@ class Tests_Widgets extends WP_UnitTestCase { array( 'before_widget' => '', 'after_widget' => '' ) ); $actual = ob_get_clean(); - + unregister_widget( 'WP_Widget_Text' ); $this->assertRegExp( '//', $actual ); diff --git a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php index e08e2752ec..ef23c7b9ef 100644 --- a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php +++ b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php @@ -22,7 +22,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { function test_no_editable_posts() { $this->make_user_by_role( 'author' ); $editor = $this->make_user_by_role( 'editor' ); - $this->factory->post->create( array( 'post_author' => $editor ) ); + self::$factory->post->create( array( 'post_author' => $editor ) ); $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); $this->assertNotInstanceOf( 'IXR_Error', $result ); @@ -32,7 +32,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { function test_date() { $this->make_user_by_role( 'author' ); - $this->factory->post->create(); + self::$factory->post->create(); $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); $this->assertNotInstanceOf( 'IXR_Error', $results ); diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php index acafda3b6c..982ab23d0a 100644 --- a/tests/phpunit/tests/xmlrpc/mw/editPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/editPost.php @@ -126,7 +126,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename, $post_id ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); // add post thumbnail to post that does not have one $post2 = array( 'wp_post_thumbnail' => $attachment_id ); @@ -141,7 +141,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // create another attachment - $attachment2_id = $this->factory->attachment->create_upload_object( $filename, $post_id ); + $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); // change the post's post_thumbnail $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); @@ -228,7 +228,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); @@ -251,7 +251,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { function test_empty_not_null() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Title', 'post_author' => $editor_id, 'tags_input' => 'taco' diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index b5d80f8d32..e8d77b7e48 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -95,7 +95,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename ); set_post_thumbnail( $this->post_id, $attachment_id ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index 0f046dce49..641fb039f6 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -100,7 +100,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename, $this->post_id ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename, $this->post_id ); set_post_thumbnail( $this->post_id, $attachment_id ); $results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) ); diff --git a/tests/phpunit/tests/xmlrpc/mw/newPost.php b/tests/phpunit/tests/xmlrpc/mw/newPost.php index 4e8d57ac66..e7804795fa 100644 --- a/tests/phpunit/tests/xmlrpc/mw/newPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/newPost.php @@ -117,7 +117,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename ); $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/deletePost.php b/tests/phpunit/tests/xmlrpc/wp/deletePost.php index fdddcf0538..93c33909bd 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deletePost.php +++ b/tests/phpunit/tests/xmlrpc/wp/deletePost.php @@ -21,7 +21,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { function test_incapable_user() { $this->make_user_by_role( 'subscriber' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) ); $this->assertInstanceOf( 'IXR_Error', $result ); @@ -30,7 +30,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { function test_post_deleted() { $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) ); $this->assertNotInstanceOf( 'IXR_Error', $result ); diff --git a/tests/phpunit/tests/xmlrpc/wp/editComment.php b/tests/phpunit/tests/xmlrpc/wp/editComment.php index aeb03e1263..9e7c1f9827 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/editComment.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { function test_author_can_edit_own_comment() { $author_id = $this->make_user_by_role( 'author' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post test by author', 'post_author' => $author_id ) ); @@ -29,7 +29,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { function test_author_cannot_edit_others_comment() { $this->make_user_by_role( 'author' ); $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post test by editor', 'post_author' => $editor_id ) ); @@ -49,7 +49,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { function test_trash_comment() { $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, @@ -78,7 +78,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { update_option( 'timezone_string', 'America/New_York' ); $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/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 538a409c87..299f3a444a 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -126,7 +126,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename, $post_id ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); // add post thumbnail to post that does not have one $post2 = array( 'post_thumbnail' => $attachment_id ); @@ -148,7 +148,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // create another attachment - $attachment2_id = $this->factory->attachment->create_upload_object( $filename, $post_id ); + $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); // change the post's post_thumbnail $post4 = array( 'post_thumbnail' => $attachment2_id ); @@ -208,7 +208,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_capable_unsticky() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) ); + $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); stick_post( $post_id ); $post2 = array( 'sticky' => false ); @@ -220,7 +220,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_password_transition_unsticky() { // when transitioning to private status or adding a post password, post should be un-stuck $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) ); + $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); stick_post( $post_id ); $post2 = array( 'post_password' => 'foobar', 'sticky' => false ); @@ -234,7 +234,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $yesterday = strtotime( '-1 day' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Revision Test', 'post_content' => 'Not edited', 'post_author' => $editor_id, @@ -263,7 +263,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_edit_attachment() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Revision Test', 'post_content' => 'Not edited', 'post_status' => 'inherit', @@ -282,7 +282,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_use_invalid_post_status() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Revision Test', 'post_content' => 'Not edited', 'post_author' => $editor_id, @@ -302,9 +302,9 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_loss_of_categories_on_edit() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) ); - $term_id = $this->factory->category->create(); - $this->factory->term->add_post_terms( $post_id, $term_id, 'category', true ); + $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); + $term_id = self::$factory->category->create(); + self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); $this->assertContains( $term_id, $term_ids ); @@ -322,9 +322,9 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_clear_categories_on_edit() { $editor_id = $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) ); - $term_id = $this->factory->category->create(); - $this->factory->term->add_post_terms( $post_id, $term_id, 'category', true ); + $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); + $term_id = self::$factory->category->create(); + self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); $this->assertContains( $term_id, $term_ids ); @@ -365,7 +365,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $editor_id = $this->make_user_by_role( 'editor' ); // Add a dummy post - $post_id = $this->factory->post->create( array( + $post_id = self::$factory->post->create( array( 'post_title' => 'Post Enclosure Test', 'post_content' => 'Fake content', 'post_author' => $editor_id, diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index 4a377739e2..f80d3573a2 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -13,7 +13,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create(); + $this->post_id = self::$factory->post->create(); $this->parent_comment_data = array( 'comment_post_ID' => $this->post_id, diff --git a/tests/phpunit/tests/xmlrpc/wp/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php index a91b95a9f4..261bf952ef 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComments.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComments.php @@ -21,8 +21,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { } function test_capable_user() { - $this->post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $this->post_id, 2 ); + $this->post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $this->post_id, 2 ); $this->make_user_by_role( 'editor' ); @@ -36,8 +36,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { } function test_post_filter() { - $this->post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $this->post_id, 2 ); + $this->post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $this->post_id, 2 ); $this->make_user_by_role( 'editor' ); @@ -52,8 +52,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { } function test_number_filter() { - $this->post_id = $this->factory->post->create(); - $this->factory->comment->create_post_comments( $this->post_id, 11 ); + $this->post_id = self::$factory->post->create(); + self::$factory->comment->create_post_comments( $this->post_id, 11 ); $this->make_user_by_role( 'editor' ); @@ -76,13 +76,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { function test_contributor_capabilities() { $this->make_user_by_role( 'contributor' ); $author_id = $this->make_user_by_role( 'author' ); - $author_post_id = $this->factory->post->create( array( + $author_post_id = self::$factory->post->create( array( 'post_title' => 'Author', 'post_author' => $author_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $author_post_id, 'comment_author' => "Commenter 1", 'comment_author_url' => "http://example.com/1/", @@ -90,13 +90,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); $editor_id = $this->make_user_by_role( 'editor' ); - $editor_post_id = $this->factory->post->create( array( + $editor_post_id = self::$factory->post->create( array( 'post_title' => 'Editor', 'post_author' => $editor_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $editor_post_id, 'comment_author' => 'Commenter 2', 'comment_author_url' => 'http://example.com/2/', @@ -110,13 +110,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { function test_author_capabilities() { $author_id = $this->make_user_by_role( 'author' ); - $author_post_id = $this->factory->post->create( array( + $author_post_id = self::$factory->post->create( array( 'post_title' => 'Author', 'post_author' => $author_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $author_post_id, 'comment_author' => 'Commenter 1', 'comment_author_url' => 'http://example.com/1/', @@ -124,13 +124,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); $editor_id = $this->make_user_by_role( 'editor' ); - $editor_post_id = $this->factory->post->create( array( + $editor_post_id = self::$factory->post->create( array( 'post_title' => 'Editor', 'post_author' => $editor_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $editor_post_id, 'comment_author' => 'Commenter 2', 'comment_author_url' => 'http://example.com/2/', @@ -166,13 +166,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { function test_editor_capabilities() { $author_id = $this->make_user_by_role( 'author' ); - $author_post_id = $this->factory->post->create( array( + $author_post_id = self::$factory->post->create( array( 'post_title' => 'Author', 'post_author' => $author_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create( array( + self::$factory->comment->create( array( 'comment_post_ID' => $author_post_id, 'comment_author' => 'Commenter 1', 'comment_author_url' => 'http://example.com/1/', @@ -180,13 +180,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { )); $editor_id = $this->make_user_by_role( 'editor' ); - $editor_post_id = $this->factory->post->create( array( + $editor_post_id = self::$factory->post->create( array( 'post_title' => 'Editor', 'post_author' => $editor_id, 'post_status' => 'publish' ) ); - $this->factory->comment->create(array( + self::$factory->comment->create(array( 'comment_post_ID' => $editor_post_id, 'comment_author' => 'Commenter 2', 'comment_author_url' => 'http://example.com/2/', diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index 489e8b923b..345a8a7c5f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -122,8 +122,8 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_valid_page() { $this->make_user_by_role( 'editor' ); - $parent_page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); - $child_page_id = $this->factory->post->create( array( + $parent_page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); + $child_page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $parent_page_id, 'menu_order' => 2 diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index 0ea79e3f53..62bac31301 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -54,7 +54,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $post_ids = array(); $num_posts = 4; foreach ( range( 1, $num_posts ) as $i ) { - $post_ids[] = $this->factory->post->create( array( + $post_ids[] = self::$factory->post->create( array( 'post_type' => $cpt_name, 'post_date' => date( 'Y-m-d H:i:s', time() + $i ) ) ); @@ -80,7 +80,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // add comments to some of the posts foreach ( $post_ids as $key => $post_id ) { // Larger post IDs will get more comments. - $this->factory->comment->create_post_comments( $post_id, $key ); + self::$factory->comment->create_post_comments( $post_id, $key ); } // get results ordered by comment count @@ -109,7 +109,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { function test_fields() { $this->make_user_by_role( 'editor' ); - $this->factory->post->create(); + self::$factory->post->create(); // check default fields $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); @@ -136,8 +136,8 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { function test_search() { $this->make_user_by_role( 'editor' ); - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) ); - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) ); + $post_ids[] = self::$factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) ); + $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) ); // Search for none of them $filter = array( 's' => rand_str() ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php index 1b013510ba..831a603bef 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php @@ -14,7 +14,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { function test_incapable_user() { $this->make_user_by_role( 'subscriber' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) ); $this->assertInstanceOf( 'IXR_Error', $result ); @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { function test_capable_user() { $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); $this->assertNotInstanceOf( 'IXR_Error', $result ); } @@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { function test_revision_count() { $this->make_user_by_role( 'editor' ); - $post_id = $this->factory->post->create(); + $post_id = self::$factory->post->create(); wp_insert_post( array( 'ID' => $post_id, 'post_content' => 'Edit 1' ) ); // Create the initial revision $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index 57537e8374..b8d1bdb442 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -106,8 +106,8 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $cat1 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) ); $cat2 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) ); - $this->factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) ); - $this->factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) ); + self::$factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) ); + self::$factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) ); $filter = array( 'orderby' => 'count', 'order' => 'DESC' ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 7adacf190e..81fc8338ce 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -79,7 +79,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { if ( is_multisite() ) grant_super_admin( $administrator_id ); - $this->factory->user->create_many( 5 ); + self::$factory->user->create_many( 5 ); $user_ids = get_users( array( 'fields' => 'ID' ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php index 3cb9eddec8..5ac6ae4976 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/newComment.php @@ -6,7 +6,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { function test_new_comment_post_closed() { $this->make_user_by_role( 'administrator' ); - $post = $this->factory->post->create_and_get( array( + $post = self::$factory->post->create_and_get( array( 'comment_status' => 'closed' ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index 5f00ddb165..4c881b8b80 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -128,7 +128,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { // create attachment $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); - $attachment_id = $this->factory->attachment->create_upload_object( $filename ); + $attachment_id = self::$factory->attachment->create_upload_object( $filename ); $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php index d6075d52c9..f53afa7bab 100644 --- a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php +++ b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php @@ -10,9 +10,9 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { function setUp() { parent::setUp(); - $this->post_id = $this->factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision + $this->post_id = self::$factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision // First saved revision on update, see https://core.trac.wordpress.org/changeset/24650 - wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) ); + wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) ); $revisions = wp_get_post_revisions( $this->post_id ); //$revision = array_shift( $revisions ); // First revision is empty - https://core.trac.wordpress.org/changeset/23842