From b757b37551f7f34de972a9ba5c27f25e9d87ee62 Mon Sep 17 00:00:00 2001
From: Scott Taylor
Date: Sat, 17 Oct 2015 18:02:16 +0000
Subject: [PATCH] Unit Tests: after [35225], make `factory` a method/getter on
`WP_UnitTestCase` and add magic methods for BC for every plugin that is
extending `WP_UnitTestCase` and accessing the `$factory` instance prop.
Props nerrad, wonderboymusic.
See #30017, #33968.
git-svn-id: https://develop.svn.wordpress.org/trunk@35242 602fd350-edb4-49c9-b593-d223f7449a82
---
.gitignore | 2 +-
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 | 27 +-
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 | 12 +-
.../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 | 14 +-
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 | 28 +-
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 | 48 +-
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 | 16 +-
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 | 20 +-
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 | 2 +-
.../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 | 2 +-
170 files changed, 2516 insertions(+), 2507 deletions(-)
diff --git a/.gitignore b/.gitignore
index dd18e54e0e..b7ac88d3de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
wp-config.php
wp-tests-config.php
.htaccess
-
+.idea
# Files and folders related to build/test tools
/phpunit.xml
/tests/phpunit/data/plugins/wordpress-importer
diff --git a/tests/phpunit/includes/testcase-ajax.php b/tests/phpunit/includes/testcase-ajax.php
index 6296ced04b..3227fa6460 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
- self::$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 = self::$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 6470a64d3b..a82c8c5e0d 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:
- // self::$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 6f69569a80..5fefb51422 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 self::$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 e7c3308a33..b92e462e83 100644
--- a/tests/phpunit/includes/testcase.php
+++ b/tests/phpunit/includes/testcase.php
@@ -14,10 +14,23 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
protected static $hooks_saved = array();
protected static $ignore_files;
- /**
- * @var WP_UnitTest_Factory
- */
- protected static $factory;
+ function __isset( $name ) {
+ return 'factory' === $name;
+ }
+
+ function __get( $name ) {
+ if ( 'factory' === $name ) {
+ return self::factory();
+ }
+ }
+
+ protected static function factory() {
+ static $factory = null;
+ if ( ! $factory ) {
+ $factory = new WP_UnitTest_Factory();
+ }
+ return $factory;
+ }
public static function get_called_class() {
if ( function_exists( 'get_called_class' ) ) {
@@ -37,16 +50,12 @@ 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;
}
- call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$factory );
+ call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() );
self::commit_transaction();
}
diff --git a/tests/phpunit/tests/admin/includesComment.php b/tests/phpunit/tests/admin/includesComment.php
index 46f3b11398..36f9897794 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 = self::$factory->post->create();
- $c1 = self::$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 = self::$factory->post->create();
- $c2 = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 a51a92924b..b7ed20dd90 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( self::$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 7fa3dd331f..8874a1c6c2 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 = self::$factory->user->create( array( 'role' => 'contributor' ) );
- $editor_id = self::$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'] = self::$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 = self::$factory->user->create( array( 'role' => 'contributor' ) );
- $editor_id = self::$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'] = self::$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 = self::$factory->user->create( array( 'role' => 'editor' ) );
+ $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $user_id );
- $post = self::$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 = self::$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 = self::$factory->term->create( array(
+ $t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'foo',
'slug' => 'bar',
) );
- $t2 = self::$factory->term->create( array(
+ $t2 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'bar',
'slug' => 'foo',
) );
- $p = self::$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 = self::$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 = self::$factory->term->create( array(
+ $t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'foo',
'slug' => 'bar',
) );
- $p = self::$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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
- $users = self::$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 = self::$factory->post->create( array(
+ $post1 = self::factory()->post->create( array(
'post_author' => $users[0],
'comment_status' => 'open',
'ping_status' => 'open',
'post_status' => 'publish',
) );
- $post2 = self::$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 = self::$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( self::$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 = self::$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( self::$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 = self::$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( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
// Published posts should use published permalink
- $p = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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%/' );
- self::$factory->post->create( array(
+ self::factory()->post->create( array(
'post_name' => '30-2',
) );
- $p = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 0ef664775a..cf83adc96c 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( self::$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( self::$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 = self::$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 = self::$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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
- $editor = self::$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 = self::$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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
- $nobody = self::$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 = self::$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 aac9274f01..4b2b26c6ec 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 = self::$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 = self::$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 = self::$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 94fc646078..87191c6a36 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( self::$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( self::$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.
- self::$factory->term->create_many( 5 );
- self::$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( self::$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 ) {
- self::$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 8b3282acc6..182894efcd 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 = self::$factory->post->create();
- $this->_comments = self::$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 9795f7b578..ba06f4271e 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 = self::$factory->post->create();
- $this->_comments = self::$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 b29690df7a..ef5c647a67 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 = self::$factory->post->create();
- self::$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 3702b0bc6d..911bf00551 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 = self::$factory->post->create();
- self::$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 = self::$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 a7ce874196..357ab1fdab 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 = self::$factory->term->create( array(
+ $t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax_1',
) );
- $t2 = self::$factory->term->create( array(
+ $t2 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax_2',
) );
// Become an administrator.
$this->_setRole( 'administrator' );
- $post = self::$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 98e7965d5c..e0f001c7b1 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 = self::$factory->post->create();
- self::$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 = self::$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 b44d5a94a0..724e6a9204 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 = self::$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 7475e45082..e777f101a9 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 = self::$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 = self::$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 = 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' ) );
+ $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 53afc8ca3a..030befa573 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', 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' ) ) );
+ 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 f734f40300..8f1dbfdab0 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 = self::$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 613e6d5f95..913f4dc776 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
- self::$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 = self::$factory->category->create_and_get(
+ $testcat = self::factory()->category->create_and_get(
array(
'slug' => 'testcat',
'name' => 'Test Category 1'
)
);
- $testcat2 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->category->create(
+ $root_id = self::factory()->category->create(
array(
'slug' => 'root',
)
);
- $root_cat_id = self::$factory->category->create(
+ $root_cat_id = self::factory()->category->create(
array(
'slug' => 'cat',
'parent' => $root_id
)
);
- $root_cat_cat_id = self::$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 = self::$factory->category->create(
+ $root_path_id = self::factory()->category->create(
array(
'slug' => 'path',
'parent' => $root_id
)
);
- $root_path_cat_id = self::$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 = self::$factory->category->create(
+ $root_level_id = self::factory()->category->create(
array(
'slug' => 'level-1',
'parent' => $root_id
)
);
- $root_level_cat_id = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->category->create( array(
+ $c1 = self::factory()->category->create( array(
'name' => 'Test Category 1',
'slug' => 'test_category_1',
) );
- $c2 = self::$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 = self::$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 = self::$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 b9c6998179..9805de9e29 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 = self::$factory->category->create_and_get();
- $this->c2 = self::$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 = self::$factory->category->create_and_get( array(
+ $c3 = self::factory()->category->create_and_get( array(
'parent' => $this->c2->term_id,
) );
- $c4 = self::$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 0a49f0f832..048f72d367 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 = self::$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 = self::$factory->category->create();
- $c2 = self::$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 = self::$factory->category->create();
- $c2 = self::$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 = self::$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 = self::$factory->category->create( array(
+ $c1 = self::factory()->category->create( array(
'name' => 'Test Cat 1',
) );
- $c2 = self::$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 = self::$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 = self::$factory->category->create_many( 2 );
- $p = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = 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 ) );
+ $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 = 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 ) );
+ $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 1fed4f4c9f..96ba7a299e 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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->user->create_and_get();
+ $user = self::factory()->user->create_and_get();
wp_set_current_user( $user->ID );
- $post = self::$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 = self::$factory->user->create_and_get( array(
+ $author = self::factory()->user->create_and_get( array(
'role' => 'author',
) );
- $user = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'role' => 'editor',
) );
wp_set_current_user( $user->ID );
- $post = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 a059149196..cf55e07db9 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 = 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 );
+ $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 = self::$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 = self::$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 = self::$factory->comment->create( array(
+ $ca1 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
) );
- $ca2 = self::$factory->comment->create( array(
+ $ca2 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
) );
- $ca3 = self::$factory->comment->create( array(
+ $ca3 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '0'
) );
- $c2 = self::$factory->comment->create( array(
+ $c2 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback'
) );
- $c3 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback'
) );
- $c4 = self::$factory->comment->create( array(
+ $c4 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario'
) );
- $c5 = self::$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 = self::$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 = self::$factory->post->create( array(
+ $p = self::factory()->post->create( array(
'post_author' => 0,
) );
- $c = self::$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 = self::$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 = self::$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 = self::$factory->comment->create( array(
+ $c1 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
) );
- $c2 = self::$factory->comment->create( array(
+ $c2 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c3 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c2,
) );
- $c4 = self::$factory->comment->create( array(
+ $c4 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c5 = self::$factory->comment->create( array(
+ $c5 = self::factory()->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
) );
- $c6 = self::$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 = self::$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 40bca3ac29..576b83871a 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 = self::$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 = self::$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 bd91dbffbd..c6bb43fd96 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 = self::$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 = self::$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 = self::$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 = self::$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 31f7cbfd1a..3e134ad9a9 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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_1 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 cccdb971dd..5859b5c298 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] = self::$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 = self::$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 09bd5c8805..a4518a226f 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 = self::$factory->post->create();
- $comment_id = self::$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 = self::$factory->post->create();
- $comment = self::$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 = self::$factory->post->create();
- $comment_id = self::$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 = self::$factory->post->create();
- $comment_id = self::$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 45ba8e798f..34e22190c8 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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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 6eee6e6689..cfb66e743d 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 = self::$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 = self::$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 0b4e44c832..c0ce30e41f 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 = self::$factory->post->create();
- $this->comments[] = self::$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[] = self::$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[] = self::$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[] = self::$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[] = self::$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[] = self::$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 d6e21bc187..9246f719e8 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 = self::$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 = 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] ) );
+ $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 = 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] ) );
+ $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 = self::$factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) );
- $comments = self::$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 390b6eda87..7de16a9b66 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 = self::$factory->post->create();
+ $p = self::factory()->post->create();
// page 4
- $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' ) );
+ $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
- 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' ) );
+ 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
- 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' ) );
+ 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
- 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' ) );
+ 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 = self::$factory->post->create();
+ $p = self::factory()->post->create();
$now = time();
$trackbacks = array();
for ( $i = 0; $i <= 3; $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 ) ) );
+ $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 ] = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $comment = self::$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 ] = 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 ) ) ) );
+ $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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 = 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 ) ) );
+ $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 = self::$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[] = 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 ) ) ) );
+ $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 = self::$factory->post->create();
+ $post = self::factory()->post->create();
$now = time();
$comment_parents = $comment_children = array();
for ( $i = 0; $i < 5; $i++ ) {
- $parent = self::$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 = 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 ) );
+ $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 = 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 ) ) );
+ $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 67563255f2..166ad25782 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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $comment_ids = self::$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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $comment_ids = self::$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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $comment_ids = self::$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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $comment_ids = self::$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 = self::$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[] = self::$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 = self::$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[] = self::$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 9a1c79b735..4ccfe8c93b 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 = self::$factory->post->create();
+ $this->post_id = self::factory()->post->create();
}
public function test_query() {
- $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' ) );
+ $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 = self::$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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = self::$factory->post->create();
- self::$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 = self::$factory->post->create();
- self::$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 = self::$factory->post->create();
- self::$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 ) );
- self::$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 = 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 ) );
+ $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 = self::$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 = self::$factory->comment->create( array(
+ $c1 = self::factory()->comment->create( array(
'comment_date' => '2015-01-28 03:00:00',
) );
- $c2 = self::$factory->comment->create( array(
+ $c2 = self::factory()->comment->create( array(
'comment_date' => '2015-01-28 05:00:00',
) );
- $c3 = self::$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 = self::$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 = self::$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 = self::$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 = 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' ) );
+ $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 = 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_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 = 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_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 = 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_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 = self::$factory->post->create();
- $p2 = self::$factory->post->create();
- $p3 = self::$factory->post->create();
+ $p1 = self::factory()->post->create();
+ $p2 = self::factory()->post->create();
+ $p3 = self::factory()->post->create();
- $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' ) );
+ $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 = self::$factory->post->create();
- $p2 = self::$factory->post->create();
- $p3 = self::$factory->post->create();
+ $p1 = self::factory()->post->create();
+ $p2 = self::factory()->post->create();
+ $p3 = self::factory()->post->create();
- $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' ) );
+ $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 = 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 ) );
+ $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 = 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' ) );
+ $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 = 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 ) );
+ $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 = 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' ) );
+ $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 = self::$factory->post->create();
- $p2 = self::$factory->post->create();
- $p3 = self::$factory->post->create();
- $p4 = self::$factory->post->create();
+ $p1 = self::factory()->post->create();
+ $p2 = self::factory()->post->create();
+ $p3 = self::factory()->post->create();
+ $p4 = self::factory()->post->create();
- $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' ) );
+ $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 = self::$factory->post->create();
- $p2 = self::$factory->post->create();
- $p3 = self::$factory->post->create();
- $p4 = self::$factory->post->create();
+ $p1 = self::factory()->post->create();
+ $p2 = self::factory()->post->create();
+ $p3 = self::factory()->post->create();
+ $p4 = self::factory()->post->create();
- $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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 = self::$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 = self::$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 = 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 ) );
+ $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 = 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 ) );
+ $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 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = 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' ) );
+ $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 = 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 );
+ $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 = self::$factory->post->create( array( 'post_name' => 'foo' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = self::$factory->post->create( array( 'post_name' => 'foo' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = 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' ) );
+ $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 = 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 );
+ $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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
- $p2 = self::$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 = self::$factory->comment->create_post_comments( $p1, 1 );
- $c2 = self::$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 = 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' ) );
+ $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 = 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 );
+ $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 = self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$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 = self::$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 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
- $c2 = self::$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 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
- $c2 = self::$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 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c4 = self::$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 = self::$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' ) );
- self::$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 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
- $c2 = self::$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'
) );
- self::$factory->comment->create( array(
+ self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- self::$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() {
- self::$factory->comment->create( array(
+ self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1'
) );
- $c2 = self::$factory->comment->create( array(
+ $c2 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1'
) );
- $c3 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1'
) );
- self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->comment->create( array(
+ $top_level_0 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
) );
- $child_of_0 = self::$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 = self::$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 = self::$factory->comment->create( array(
+ $top_level_0 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
) );
- $child_of_0 = self::$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 = self::$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 = self::$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(
+ $c2 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c3 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c2,
) );
- $c4 = self::$factory->comment->create( array(
+ $c4 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c5 = self::$factory->comment->create( array(
+ $c5 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
) );
- $c6 = self::$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 = self::$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(
+ $c2 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c3 = self::$factory->comment->create( array(
+ $c3 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '0',
'comment_parent' => $c2,
) );
- $c4 = self::$factory->comment->create( array(
+ $c4 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
- $c5 = self::$factory->comment->create( array(
+ $c5 = self::factory()->comment->create( array(
'comment_post_ID' => $this->post_id,
'comment_approved' => '1',
) );
- self::$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 = self::$factory->post->create();
- $c = self::$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 = self::$factory->post->create();
- $c = self::$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 01b4e99e49..6a87ab510c 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 = self::$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 = self::$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 = self::$factory->post->create();
- $comment_id = self::$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 = self::$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 = self::$factory->post->create();
- $comment_id = self::$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 8556cb0db1..00fd2b8b95 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 = self::$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 ) ) );
- self::$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 = self::$factory->post->create();
+ $post_id = self::factory()->post->create();
$permalink = get_permalink( $post_id );
$this->go_to( $permalink );
$this->assertEquals( 0, get_comments_number() );
- self::$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 8dd2607150..fcd4f69907 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 = self::$factory->post->create();
+ $this->post_id = self::factory()->post->create();
}
/**
* @ticket 14041
*/
function test_has_children() {
- $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 = 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 b618fbeef1..4165d36100 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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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 = self::$factory->post->create( array(
+ $post_id = self::factory()->post->create( array(
'post_status' => 'publish'
) );
- $comment_id = self::$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 ec9e2b05c4..b9e7f31112 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( self::$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( self::$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( self::$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 fab713e837..ad2e7d2494 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( self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
- $second_post_id = self::$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 = self::$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 = self::$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 = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
- $second_post_id = self::$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 = self::$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 = self::$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 7f4616c456..a3438c9932 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( self::$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 5add12999b..dd620c3c30 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( self::$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.
- self::$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 = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
+ $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) );
// Create pages.
- self::$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 = self::$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 = self::$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 = self::$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[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) );
- $post_ids[] = self::$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[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
- $term_ids[] = self::$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 = self::$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 f1b62cb9e6..13359a1c7c 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 = self::$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( self::$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( self::$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( self::$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 2ed81b675e..dad67ed802 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 = self::$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( self::$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( self::$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( self::$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 803f09088b..296554b08d 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( self::$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 = self::$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 6dd47d017a..65843412e3 100644
--- a/tests/phpunit/tests/customize/widgets.php
+++ b/tests/phpunit/tests/customize/widgets.php
@@ -38,7 +38,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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
+ $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $user_id );
$this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
diff --git a/tests/phpunit/tests/date/query.php b/tests/phpunit/tests/date/query.php
index 7ce816572e..cc848be868 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 = 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' ) );
+ $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 = 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' ) );
+ $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 = 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' ) );
+ $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 fd3517db1c..74036a2027 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 = self::$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 691c0822bc..c741214f07 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 = self::$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 8aafa8e0f1..da508c7712 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 = self::$factory->post->create( array(
+ $post1 = self::factory()->post->create( array(
'post_content' => 'Post 1 Page 1Post 1 Page 2',
) );
- $post2 = self::$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 = self::$factory->post->create( array(
+ $post1 = self::factory()->post->create( array(
'post_content' => 'Post 1 Page 1Post 1 Page 2',
) );
- $post2 = self::$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 d44f47060c..1119770c97 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'] = self::$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 393808d73a..2d70387b0b 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() {
- self::$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 ) );
- self::$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 e34e6c1a36..3e10f2a820 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;
- self::$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 e7c6929646..3eef943d56 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 = self::$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 08275d11bd..272b4cdcd1 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 = self::$factory->post->create();
- $post_id2 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->term->create( array(
+ $include = self::factory()->term->create( array(
'taxonomy' => 'category',
'name' => 'Include',
) );
- $exclude = self::$factory->category->create();
+ $exclude = self::factory()->category->create();
- $one = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->term->create( array(
+ $t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
- $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' ) );
+ $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 = self::$factory->term->create( array(
+ $t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
- $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' ) );
+ $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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 08064e1db1..68c511d35c 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 = self::$factory->category->create( array( 'name' => 'other' ) );
+ $this->cat_id = self::factory()->category->create( array( 'name' => 'other' ) );
$this->post_ids = array();
- $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 ) );
+ $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;
diff --git a/tests/phpunit/tests/link/getNextCommentsLink.php b/tests/phpunit/tests/link/getNextCommentsLink.php
index 8f148dba55..204b2057ff 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 = self::$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 = self::$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 e3972fccc5..5e1eddc012 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 = self::$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 = self::$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 = self::$factory->post->create();
- $attachment_id = self::$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 = self::$factory->post->create( array(
+ $post_id = self::factory()->post->create( array(
'post_status' => 'publish'
) );
- $attachment_id = self::$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 = self::$factory->post->create();
- $attachment_id = self::$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 = self::$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 = self::$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 ea9ad6ccd5..ff4c088dea 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 = self::$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 = self::$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 b68a5377fa..24fbfd4e66 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 = self::$factory->post->create();
- $attachment_id = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create();
- $attachment_id = self::$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 = self::$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 e975d6a9fa..0676c7ec0f 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( self::$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 = self::$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 = self::$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 = self::$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 3f876d284a..a5da86f428 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 = self::$factory->user->create( array( 'role' => 'editor' ) );
- $this->post_id = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 b9fb2adf7f..c2fabbf2b2 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 = self::$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 = self::$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 = self::$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 = self::$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 bd355cc13c..cbc5138453 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 = self::$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 = self::$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 = self::$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 = self::$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 611e8432ed..8bc87df7d2 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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
- $blog_id2 = self::$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 = self::$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 01160ad096..5888c73490 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() {
- self::$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 = self::$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 = self::$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' );
- self::$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 = self::$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' );
- self::$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 = self::$factory->user->create( array( 'role' => 'administrator' ) );
- $blog_id = self::$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 0a51e6a43d..8afdbe8fb6 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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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.
- self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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() {
- self::$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)
- self::$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() {
- self::$factory->post->create();
- $post2 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->blog->create();
- $post_id = self::$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 = self::$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 874d2bceec..e106b026f0 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 = self::$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 = self::$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 50ddce79b4..15cf56ca44 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 = self::$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 = self::$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 9c9275baaa..bf646f599e 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 = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'display_name' => 'John Doe',
) );
- $post = self::$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 = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'display_name' => 'John Doe',
) );
- $post = self::$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 = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'display_name' => 'John Doe',
) );
- $post = self::$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 = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'display_name' => 'John Doe',
) );
- $post = self::$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 = self::$factory->blog->create();
+ $child = self::factory()->blog->create();
switch_to_blog( $child );
- $post = self::$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 = self::$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 ef78befcfa..e7615f9056 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 = self::$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 = self::$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 = self::$factory->post->create();
+ $post_id = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
- $attachment_id = self::$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 0891642c37..6dcdcbd1bf 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 = self::$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 = self::$factory->user->create( array(
+ $user_id = self::factory()->user->create( array(
'display_name' => 'John Doe',
) );
- $post = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create_and_get();
+ $post = self::factory()->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
- $attachment_id = self::$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 = self::$factory->post->create();
+ $parent = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
- $post = self::$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 247e947b98..3c9f80fcc6 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 = self::$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 = self::$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 1972bac098..dda0f3c42d 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 = self::$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 = self::$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 94d0d9cf83..da61db4102 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 = self::$factory->user->create_and_get( array(
+ $user = self::factory()->user->create_and_get( array(
'display_name' => 'John Doe',
) );
- $post_id = self::$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 = self::$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 = self::$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 = self::$factory->post->create_and_get();
+ $post = self::factory()->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
- $attachment_id = self::$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 = self::$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 = self::$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 = self::$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 = self::$factory->user->create( array( 'role' => 'editor' ) );
+ $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $user_id );
- $post_id = self::$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_embed_excerpt_more() {
- $post_id = self::$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 = self::$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 = self::$factory->post->create();
+ $post_id = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
- $attachment_id = self::$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 = self::$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 627b655d5d..5cde7ba126 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 = self::$factory->user->create();
+ $user_id = self::factory()->user->create();
$this->assertInternalType( 'integer', $user_id );
- $blog_id = self::$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 f57c7963cb..1e0bd71b97 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 = self::$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 = self::$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 = self::$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 0c0aa3dc8e..4da33e5659 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 = self::$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 17a93e4752..df1ab0a6f6 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 = 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' ) );
+ $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 = self::$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 = self::$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 = self::$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 = self::$factory->post->create( array( 'post_name' => 'parent' ) );
- $child_id = self::$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 = self::$factory->post->create();
- $post = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 );
- self::$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 );
- self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 faabf28ab7..91e79cf88a 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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 ecb9bf2cb9..c28e19e802 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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 = self::$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 1592ad1a5f..d7b89e8005 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 = self::$factory->post->create();
+ $this->post_id = self::factory()->post->create();
}
/**
* @ticket 30883
*/
public function test_with_utf8_category_slugs() {
- $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кадр' ) );
+ $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 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) );
- $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) );
- $tag_id3 = self::$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 = 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кадр' ) );
+ $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 a9cf113222..5391815aa0 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;
- self::$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 = self::$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[] = self::$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 = 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 ) );
+ $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() {
- self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) );
+ self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) );
preg_match_all( '#