Unit Tests: one $factory to rule them all, and it shall be static.

Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`.

Replace `$this->factory` with `self::$factory` over 2000 times.
Rewrite all of the tests that were hard-coding dynamic values. 

#YOLOFriday



git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-10-16 21:04:12 +00:00
parent 84272ff8cd
commit e70ebea219
169 changed files with 2631 additions and 2616 deletions

View File

@ -75,7 +75,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
error_reporting( $this->_error_level & ~E_WARNING );
// Make some posts
$this->factory->post->create_many( 5 );
self::$factory->post->create_many( 5 );
}
/**
@ -148,7 +148,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
*/
protected function _setRole( $role ) {
$post = $_POST;
$user_id = $this->factory->user->create( array( 'role' => $role ) );
$user_id = self::$factory->user->create( array( 'role' => $role ) );
wp_set_current_user( $user_id );
$_POST = array_merge($_POST, $post);
}

View File

@ -49,7 +49,7 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
wp_set_current_user( self::$author_id );
// Already created by install defaults:
// $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) );
// self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) );
self::$post_ids[] = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) );
self::$post_ids[] = $post_id = $factory->post->create( array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' ) );

View File

@ -22,7 +22,7 @@ class WP_XMLRPC_UnitTestCase extends WP_UnitTestCase {
}
protected function make_user_by_role( $role ) {
return $this->factory->user->create( array(
return self::$factory->user->create( array(
'user_login' => $role,
'user_pass' => $role,
'role' => $role

View File

@ -17,9 +17,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
/**
* @var WP_UnitTest_Factory
*/
protected $factory;
protected static $static_factory;
protected static $factory;
public static function get_called_class() {
if ( function_exists( 'get_called_class' ) ) {
@ -39,16 +37,16 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
if ( ! self::$factory ) {
self::$factory = new WP_UnitTest_Factory();
}
$c = self::get_called_class();
if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
return;
}
if ( ! self::$static_factory ) {
self::$static_factory = new WP_UnitTest_Factory();
}
call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$static_factory );
call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$factory );
self::commit_transaction();
}
@ -82,7 +80,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
$wpdb->show_errors = true;
$wpdb->db_connect();
ini_set('display_errors', 1 );
$this->factory = new WP_UnitTest_Factory;
$this->clean_up_global_scope();
/*

View File

@ -6,15 +6,15 @@
*/
class Tests_Admin_IncludesComment extends WP_UnitTestCase {
public function test_must_match_date_and_author() {
$p1 = $this->factory->post->create();
$c1 = $this->factory->comment->create( array(
$p1 = self::$factory->post->create();
$c1 = self::$factory->comment->create( array(
'comment_author' => 1,
'comment_date' => '2014-05-06 12:00:00',
'comment_post_ID' => $p1,
) );
$p2 = $this->factory->post->create();
$c2 = $this->factory->comment->create( array(
$p2 = self::$factory->post->create();
$c2 = self::$factory->comment->create( array(
'comment_author' => 2,
'comment_date' => '2004-01-02 12:00:00',
'comment_post_ID' => $p2,
@ -28,8 +28,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
* @ticket 33871
*/
public function test_default_value_of_timezone_should_be_blog() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array(
'comment_author' => 1,
'comment_post_ID' => $p,
'comment_date' => '2014-05-06 12:00:00',
@ -43,8 +43,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
* @ticket 33871
*/
public function test_should_respect_timezone_blog() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array(
'comment_author' => 1,
'comment_post_ID' => $p,
'comment_date' => '2014-05-06 12:00:00',
@ -58,8 +58,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
* @ticket 33871
*/
public function test_should_respect_timezone_gmt() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array(
'comment_author' => 1,
'comment_post_ID' => $p,
'comment_date' => '2014-05-06 12:00:00',
@ -73,8 +73,8 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
* @ticket 33871
*/
public function test_invalid_timezone_should_fall_back_on_blog() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array(
'comment_author' => 1,
'comment_post_ID' => $p,
'comment_date' => '2014-05-06 12:00:00',

View File

@ -29,7 +29,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
function test_menu_page_url() {
$current_user = get_current_user_id();
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
update_option( 'siteurl', 'http://example.com' );
// add some pages

View File

@ -11,8 +11,8 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
}
function test__wp_translate_postdata_cap_checks_contributor() {
$contributor_id = $this->factory->user->create( array( 'role' => 'contributor' ) );
$editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) );
$editor_id = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $contributor_id );
@ -51,7 +51,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
// Edit Draft Post for another user
$_post_data = array();
$_post_data['post_ID'] = $this->factory->post->create( array( 'post_author' => $editor_id ) );
$_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $editor_id ) );
$_post_data['post_author'] = $editor_id;
$_post_data['post_type'] = 'post';
$_post_data['post_status'] = 'draft';
@ -64,8 +64,8 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
}
function test__wp_translate_postdata_cap_checks_editor() {
$contributor_id = $this->factory->user->create( array( 'role' => 'contributor' ) );
$editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) );
$editor_id = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $editor_id );
@ -104,7 +104,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
// Edit Draft Post for another user
$_post_data = array();
$_post_data['post_ID'] = $this->factory->post->create( array( 'post_author' => $contributor_id ) );
$_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $contributor_id ) );
$_post_data['post_author'] = $contributor_id;
$_post_data['post_type'] = 'post';
$_post_data['post_status'] = 'draft';
@ -122,9 +122,9 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
* @ticket 25272
*/
function test_edit_post_auto_draft() {
$user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $user_id );
$post = $this->factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
$post = self::$factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
$this->assertEquals( 'auto-draft', $post->post_status );
$post_data = array(
'post_title' => 'Post title',
@ -140,22 +140,22 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
* @ticket 30615
*/
public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() {
$u = $this->factory->user->create( array( 'role' => 'editor' ) );
$u = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $u );
register_taxonomy( 'wptests_tax', array( 'post' ) );
$t1 = $this->factory->term->create( array(
$t1 = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'foo',
'slug' => 'bar',
) );
$t2 = $this->factory->term->create( array(
$t2 = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'bar',
'slug' => 'foo',
) );
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$post_data = array(
'post_ID' => $p,
@ -179,17 +179,17 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
* @ticket 30615
*/
public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() {
$u = $this->factory->user->create( array( 'role' => 'editor' ) );
$u = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $u );
register_taxonomy( 'wptests_tax', array( 'post' ) );
$t1 = $this->factory->term->create( array(
$t1 = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'foo',
'slug' => 'bar',
) );
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$post_data = array(
'post_ID' => $p,
@ -209,18 +209,18 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
* @ticket 27792
*/
function test_bulk_edit_posts_stomping() {
$admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
$users = $this->factory->user->create_many( 2, array( 'role' => 'author' ) );
$admin = self::$factory->user->create( array( 'role' => 'administrator' ) );
$users = self::$factory->user->create_many( 2, array( 'role' => 'author' ) );
wp_set_current_user( $admin );
$post1 = $this->factory->post->create( array(
$post1 = self::$factory->post->create( array(
'post_author' => $users[0],
'comment_status' => 'open',
'ping_status' => 'open',
'post_status' => 'publish',
) );
$post2 = $this->factory->post->create( array(
$post2 = self::$factory->post->create( array(
'post_author' => $users[1],
'comment_status' => 'closed',
'ping_status' => 'closed',
@ -255,7 +255,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
$this->set_permalink_structure( "/$permalink_structure/" );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$found = get_sample_permalink( $p );
$expected = trailingslashit( home_url( $permalink_structure ) );
@ -268,10 +268,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
* @ticket 18306
*/
public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$found = get_sample_permalink_html( $p );
$this->assertContains( 'href="' . get_option( 'home' ) . '/?p=' . $p . '"', $found );
@ -284,10 +284,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() {
$this->set_permalink_structure( '/%postname%/' );
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
$found = get_sample_permalink_html( $p );
$post = get_post( $p );
@ -301,10 +301,10 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() {
$this->set_permalink_structure( '/%postname%/' );
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
// Published posts should use published permalink
$p = $this->factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );
$p = self::$factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );
$found = get_sample_permalink_html( $p, null, 'new_slug' );
$post = get_post( $p );
@ -313,7 +313,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
// Scheduled posts should use published permalink
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) );
$p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) );
$found = get_sample_permalink_html( $p, null, 'new_slug' );
$post = get_post( $p );
@ -321,7 +321,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
$this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message );
// Draft posts should use preview link
$p = $this->factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) );
$p = self::$factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) );
$found = get_sample_permalink_html( $p, null, 'new_slug' );
$post = get_post( $p );
@ -339,7 +339,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() {
$this->set_permalink_structure( '/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '2015',
) );
@ -353,7 +353,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '2015',
) );
@ -367,7 +367,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '11',
) );
@ -381,7 +381,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '13',
) );
@ -395,7 +395,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() {
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '30',
) );
@ -409,11 +409,11 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() {
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$this->factory->post->create( array(
self::$factory->post->create( array(
'post_name' => '30-2',
) );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '30',
) );
@ -427,7 +427,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() {
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '32',
) );
@ -441,7 +441,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
$this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_name' => '30',
) );
@ -450,7 +450,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
}
public function test_post_exists_should_match_title() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => 'Foo Bar',
) );
@ -458,7 +458,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
}
public function test_post_exists_should_not_match_nonexistent_title() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => 'Foo Bar',
) );
@ -468,7 +468,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_post_exists_should_match_nonempty_content() {
$title = 'Foo Bar';
$content = 'Foo Bar Baz';
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => $title,
'post_content' => $content,
) );
@ -479,7 +479,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() {
$title = 'Foo Bar';
$content = 'Foo Bar Baz';
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => $title,
'post_content' => $content . ' Quz',
) );
@ -490,7 +490,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_post_exists_should_match_nonempty_date() {
$title = 'Foo Bar';
$date = '2014-05-08 12:00:00';
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => $title,
'post_date' => $date,
) );
@ -501,7 +501,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() {
$title = 'Foo Bar';
$date = '2014-05-08 12:00:00';
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => $title,
'post_date' => '2015-10-10 00:00:00',
) );
@ -513,7 +513,7 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
$title = 'Foo Bar';
$content = 'Foo Bar Baz';
$date = '2014-05-08 12:00:00';
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_title' => $title,
'post_content' => $content,
'post_date' => $date,

View File

@ -15,7 +15,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
* @ticket 21117
*/
function test_content_post_type() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
register_post_type( 'content', array( 'show_in_admin_bar' => true ) );
@ -34,7 +34,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
* @ticket 21117
*/
function test_merging_existing_meta_values() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
$admin_bar = new WP_Admin_Bar;
@ -62,7 +62,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
$this->markTestSkipped( 'Test does not run in multisite' );
}
$nobody = $this->factory->user->create( array( 'role' => '' ) );
$nobody = self::$factory->user->create( array( 'role' => '' ) );
$this->assertFalse( user_can( $nobody, 'read' ) );
wp_set_current_user( $nobody );
@ -92,7 +92,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
$this->markTestSkipped( 'Test does not run in multisite' );
}
$editor = $this->factory->user->create( array( 'role' => 'editor' ) );
$editor = self::$factory->user->create( array( 'role' => 'editor' ) );
$this->assertTrue( user_can( $editor, 'read' ) );
wp_set_current_user( $editor );
@ -125,13 +125,13 @@ class Tests_AdminBar extends WP_UnitTestCase {
$this->markTestSkipped( 'Test only runs in multisite' );
}
$admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
$editor = $this->factory->user->create( array( 'role' => 'editor' ) );
$admin = self::$factory->user->create( array( 'role' => 'administrator' ) );
$editor = self::$factory->user->create( array( 'role' => 'editor' ) );
$this->assertTrue( user_can( $admin, 'read' ) );
$this->assertTrue( user_can( $editor, 'read' ) );
$new_blog_id = $this->factory->blog->create( array(
$new_blog_id = self::$factory->blog->create( array(
'user_id' => $admin,
) );
@ -179,13 +179,13 @@ class Tests_AdminBar extends WP_UnitTestCase {
$this->markTestSkipped( 'Test only runs in multisite' );
}
$admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
$nobody = $this->factory->user->create( array( 'role' => '' ) );
$admin = self::$factory->user->create( array( 'role' => 'administrator' ) );
$nobody = self::$factory->user->create( array( 'role' => '' ) );
$this->assertTrue( user_can( $admin, 'read' ) );
$this->assertFalse( user_can( $nobody, 'read' ) );
$new_blog_id = $this->factory->blog->create( array(
$new_blog_id = self::$factory->blog->create( array(
'user_id' => $admin,
) );

View File

@ -33,10 +33,10 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
public function setUp() {
parent::setUp();
// Set a user so the $post has 'post_author'
$this->user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $this->user_id );
$post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );
$post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
$this->_post = get_post( $post_id );
}
@ -97,7 +97,7 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
*/
public function test_autosave_locked_post() {
// Lock the post to another user
$another_user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$another_user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $another_user_id );
wp_set_post_lock( $this->_post->ID );

View File

@ -22,7 +22,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
public function setUp() {
parent::setUp();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
@ -65,7 +65,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
$this->setExpectedException( 'WPAjaxDieStopException' );
}
wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) );
$_POST = array(
'action' => 'load-available-menu-items-customizer',
@ -307,8 +307,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
);
// Create some terms and pages.
$this->factory->term->create_many( 5 );
$this->factory->post->create_many( 5, array( 'post_type' => 'page' ) );
self::$factory->term->create_many( 5 );
self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) );
$_POST = array_merge( array(
'action' => 'load-available-menu-items-customizer',
@ -396,7 +396,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
$this->setExpectedException( 'WPAjaxDieStopException' );
}
wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) );
$_POST = array(
'action' => 'search-available-menu-items-customizer',
@ -469,7 +469,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
*/
function test_ajax_search_available_items_results( $post_args, $expected_results ) {
$this->factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
self::$factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
$_POST = array_merge( array(
'action' => 'search-available-menu-items-customizer',

View File

@ -26,8 +26,8 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*/
public function setUp() {
parent::setUp();
$post_id = $this->factory->post->create();
$this->_comments = $this->factory->comment->create_post_comments( $post_id, 15 );
$post_id = self::$factory->post->create();
$this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 );
$this->_comments = array_map( 'get_comment', $this->_comments );
}

View File

@ -26,8 +26,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase {
*/
public function setUp() {
parent::setUp();
$post_id = $this->factory->post->create();
$this->_comments = $this->factory->comment->create_post_comments( $post_id, 15 );
$post_id = self::$factory->post->create();
$this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 );
$this->_comments = array_map( 'get_comment', $this->_comments );
}

View File

@ -26,8 +26,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase {
*/
public function setUp() {
parent::setUp();
$post_id = $this->factory->post->create();
$this->factory->comment->create_post_comments( $post_id, 5 );
$post_id = self::$factory->post->create();
self::$factory->comment->create_post_comments( $post_id, 5 );
$this->_comment_post = get_post( $post_id );
}

View File

@ -32,11 +32,11 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase {
*/
public function setUp() {
parent::setUp();
$post_id = $this->factory->post->create();
$this->factory->comment->create_post_comments( $post_id, 5 );
$post_id = self::$factory->post->create();
self::$factory->comment->create_post_comments( $post_id, 5 );
$this->_comment_post = get_post( $post_id );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->_no_comment_post = get_post( $post_id );
unset( $GLOBALS['post_id'] );

View File

@ -25,17 +25,17 @@ class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase {
'hierarchical' => true,
) );
$t1 = $this->factory->term->create( array(
$t1 = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax_1',
) );
$t2 = $this->factory->term->create( array(
$t2 = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax_2',
) );
// Become an administrator.
$this->_setRole( 'administrator' );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_author' => get_current_user_id(),
) );

View File

@ -32,11 +32,11 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase {
*/
public function setUp() {
parent::setUp();
$post_id = $this->factory->post->create();
$this->factory->comment->create_post_comments( $post_id, 5 );
$post_id = self::$factory->post->create();
self::$factory->comment->create_post_comments( $post_id, 5 );
$this->_comment_post = get_post( $post_id );
$post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );
$post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
$this->_draft_post = get_post( $post_id );
}

View File

@ -8,7 +8,7 @@
class Tests_Attachment_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
$this->old_current_user = get_current_user_id();
wp_set_current_user( $this->author_id );

View File

@ -87,12 +87,12 @@ class Tests_Avatar extends WP_UnitTestCase {
$url2 = get_avatar_url( $user );
$this->assertEquals( $url, $url2 );
$post_id = $this->factory->post->create( array( 'post_author' => 1 ) );
$post_id = self::$factory->post->create( array( 'post_author' => 1 ) );
$post = get_post( $post_id );
$url2 = get_avatar_url( $post );
$this->assertEquals( $url, $url2 );
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) );
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) );
$comment = get_comment( $comment_id );
$url2 = get_avatar_url( $comment );
$this->assertEquals( $url, $url2 );
@ -138,8 +138,8 @@ class Tests_Avatar extends WP_UnitTestCase {
public function test_get_avatar_comment_types_filter() {
$url = get_avatar_url( 1 );
$post_id = $this->factory->post->create( array( 'post_author' => 1 ) );
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) );
$post_id = self::$factory->post->create( array( 'post_author' => 1 ) );
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) );
$comment = get_comment( $comment_id );
$url2 = get_avatar_url( $comment );

View File

@ -18,8 +18,8 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
parent::setUp();
update_option( 'show_on_front', 'page' );
update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
update_option( 'page_for_posts', self::$factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
update_option( 'page_on_front', self::$factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
}
/**

View File

@ -12,7 +12,7 @@ class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase {
This is a paragraph.';
$next = '<!--nextpage-->';
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_status' => 'publish',
'post_content' => "{$para}{$next}{$para}{$next}{$para}"
) );

View File

@ -21,7 +21,7 @@ class Tests_Category extends WP_UnitTestCase {
*/
function test_get_all_category_ids() {
// create categories
$this->factory->category->create_many( 2 );
self::$factory->category->create_many( 2 );
// create new taxonomy to ensure not included
register_taxonomy( 'test_tax_cat', 'post' );
@ -38,13 +38,13 @@ class Tests_Category extends WP_UnitTestCase {
function test_get_category_by_slug() {
// create Test Categories
$testcat = $this->factory->category->create_and_get(
$testcat = self::$factory->category->create_and_get(
array(
'slug' => 'testcat',
'name' => 'Test Category 1'
)
);
$testcat2 = $this->factory->category->create_and_get(
$testcat2 = self::$factory->category->create_and_get(
array(
'slug' => 'testcat2',
'name' => 'Test Category 2'
@ -73,7 +73,7 @@ class Tests_Category extends WP_UnitTestCase {
'name' => 'Test MCC',
'description' => 'Category Test'
);
$testcat = $this->factory->category->create_and_get( $testcat_array );
$testcat = self::$factory->category->create_and_get( $testcat_array );
$testcat_array['term_id'] = $testcat->term_id;
$testcat2_array = array(
@ -82,7 +82,7 @@ class Tests_Category extends WP_UnitTestCase {
'description' => 'Category Test',
'parent' => $testcat->term_id
);
$testcat2 = $this->factory->category->create_and_get( $testcat2_array );
$testcat2 = self::$factory->category->create_and_get( $testcat2_array );
$testcat2_array['term_id'] = $testcat2->term_id;
// unset properties to enable validation of object
@ -145,7 +145,7 @@ class Tests_Category extends WP_UnitTestCase {
function test_get_cat_name() {
// create Test Category
$testcat = $this->factory->category->create_and_get(
$testcat = self::$factory->category->create_and_get(
array(
'slug' => 'testcat',
'name' => 'Test Category 1'
@ -165,7 +165,7 @@ class Tests_Category extends WP_UnitTestCase {
function test_get_cat_ID() {
// create Test Category
$testcat = $this->factory->category->create_and_get(
$testcat = self::$factory->category->create_and_get(
array(
'slug' => 'testcat',
'name' => 'Test Category 1'
@ -185,42 +185,42 @@ class Tests_Category extends WP_UnitTestCase {
function test_get_category_by_path() {
// create Test Categories
$root_id = $this->factory->category->create(
$root_id = self::$factory->category->create(
array(
'slug' => 'root',
)
);
$root_cat_id = $this->factory->category->create(
$root_cat_id = self::$factory->category->create(
array(
'slug' => 'cat',
'parent' => $root_id
)
);
$root_cat_cat_id = $this->factory->category->create(
$root_cat_cat_id = self::$factory->category->create(
array(
'slug' => 'cat', //note this is modified on create
'parent' => $root_cat_id
)
);
$root_path_id = $this->factory->category->create(
$root_path_id = self::$factory->category->create(
array(
'slug' => 'path',
'parent' => $root_id
)
);
$root_path_cat_id = $this->factory->category->create(
$root_path_cat_id = self::$factory->category->create(
array(
'slug' => 'cat', //note this is modified on create
'parent' => $root_path_id
)
);
$root_level_id = $this->factory->category->create(
$root_level_id = self::$factory->category->create(
array(
'slug' => 'level-1',
'parent' => $root_id
)
);
$root_level_cat_id = $this->factory->category->create(
$root_level_cat_id = self::$factory->category->create(
array(
'slug' => 'cat', //note this is modified on create
'parent' => $root_level_id
@ -248,7 +248,7 @@ class Tests_Category extends WP_UnitTestCase {
*/
public function test_wp_dropdown_categories_value_field_should_default_to_term_id() {
// Create a test category.
$cat_id = $this->factory->category->create( array(
$cat_id = self::$factory->category->create( array(
'name' => 'Test Category',
'slug' => 'test_category',
) );
@ -268,7 +268,7 @@ class Tests_Category extends WP_UnitTestCase {
*/
public function test_wp_dropdown_categories_value_field_term_id() {
// Create a test category.
$cat_id = $this->factory->category->create( array(
$cat_id = self::$factory->category->create( array(
'name' => 'Test Category',
'slug' => 'test_category',
) );
@ -289,7 +289,7 @@ class Tests_Category extends WP_UnitTestCase {
*/
public function test_wp_dropdown_categories_value_field_slug() {
// Create a test category.
$cat_id = $this->factory->category->create( array(
$cat_id = self::$factory->category->create( array(
'name' => 'Test Category',
'slug' => 'test_category',
) );
@ -310,7 +310,7 @@ class Tests_Category extends WP_UnitTestCase {
*/
public function test_wp_dropdown_categories_value_field_should_fall_back_on_term_id_when_an_invalid_value_is_provided() {
// Create a test category.
$cat_id = $this->factory->category->create( array(
$cat_id = self::$factory->category->create( array(
'name' => 'Test Category',
'slug' => 'test_category',
) );
@ -330,12 +330,12 @@ class Tests_Category extends WP_UnitTestCase {
* @ticket 32330
*/
public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() {
$c1 = $this->factory->category->create( array(
$c1 = self::$factory->category->create( array(
'name' => 'Test Category 1',
'slug' => 'test_category_1',
) );
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'name' => 'Test Category 2',
'slug' => 'test_category_2',
) );
@ -354,7 +354,7 @@ class Tests_Category extends WP_UnitTestCase {
* @ticket 33452
*/
public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_no_selected_value_is_explicitly_passed_and_value_field_does_not_have_string_values() {
$cats = $this->factory->category->create_many( 3 );
$cats = self::$factory->category->create_many( 3 );
$found = wp_dropdown_categories( array(
'echo' => 0,
@ -375,7 +375,7 @@ class Tests_Category extends WP_UnitTestCase {
* @ticket 33452
*/
public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_selected_value_of_0_string_is_explicitly_passed_and_value_field_does_not_have_string_values() {
$cats = $this->factory->category->create_many( 3 );
$cats = self::$factory->category->create_many( 3 );
$found = wp_dropdown_categories( array(
'echo' => 0,

View File

@ -10,8 +10,8 @@ class Tests_Category_GetCategoryParents extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
$this->c1 = $this->factory->category->create_and_get();
$this->c2 = $this->factory->category->create_and_get( array(
$this->c1 = self::$factory->category->create_and_get();
$this->c2 = self::$factory->category->create_and_get( array(
'parent' => $this->c1->term_id,
) );
}
@ -51,10 +51,10 @@ class Tests_Category_GetCategoryParents extends WP_UnitTestCase {
}
public function test_visited() {
$c3 = $this->factory->category->create_and_get( array(
$c3 = self::$factory->category->create_and_get( array(
'parent' => $this->c2->term_id,
) );
$c4 = $this->factory->category->create_and_get( array(
$c4 = self::$factory->category->create_and_get( array(
'parent' => $c3->term_id,
) );

View File

@ -5,7 +5,7 @@
*/
class Tests_Category_WpListCategories extends WP_UnitTestCase {
public function test_class() {
$c = $this->factory->category->create();
$c = self::$factory->category->create();
$found = wp_list_categories( array(
'hide_empty' => false,
@ -16,8 +16,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
}
public function test_class_containing_current_cat() {
$c1 = $this->factory->category->create();
$c2 = $this->factory->category->create();
$c1 = self::$factory->category->create();
$c2 = self::$factory->category->create();
$found = wp_list_categories( array(
'hide_empty' => false,
@ -30,8 +30,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
}
public function test_class_containing_current_cat_parent() {
$c1 = $this->factory->category->create();
$c2 = $this->factory->category->create( array(
$c1 = self::$factory->category->create();
$c2 = self::$factory->category->create( array(
'parent' => $c1,
) );
@ -49,7 +49,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
* @ticket 33565
*/
public function test_current_category_should_accept_an_array_of_ids() {
$cats = $this->factory->category->create_many( 3 );
$cats = self::$factory->category->create_many( 3 );
$found = wp_list_categories( array(
'echo' => false,
@ -66,10 +66,10 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
* @ticket 16792
*/
public function test_should_not_create_element_when_cat_name_is_filtered_to_empty_string() {
$c1 = $this->factory->category->create( array(
$c1 = self::$factory->category->create( array(
'name' => 'Test Cat 1',
) );
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'name' => 'Test Cat 2',
) );
@ -88,7 +88,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
}
public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {
$cats = $this->factory->category->create_many( 2 );
$cats = self::$factory->category->create_many( 2 );
$found = wp_list_categories( array(
'echo' => false,
@ -101,8 +101,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
}
public function test_show_option_all_link_should_respect_page_for_posts() {
$cats = $this->factory->category->create_many( 2 );
$p = $this->factory->post->create( array( 'post_type' => 'page' ) );
$cats = self::$factory->category->create_many( 2 );
$p = self::$factory->post->create( array( 'post_type' => 'page' ) );
update_option( 'show_on_front', 'page' );
update_option( 'page_for_posts', $p );
@ -125,7 +125,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = $this->factory->term->create_many( 2, array(
$terms = self::$factory->term->create_many( 2, array(
'taxonomy' => 'wptests_tax',
) );
@ -149,7 +149,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = $this->factory->term->create_many( 2, array(
$terms = self::$factory->term->create_many( 2, array(
'taxonomy' => 'wptests_tax',
) );
@ -170,7 +170,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) );
$terms = $this->factory->term->create_many( 2, array(
$terms = self::$factory->term->create_many( 2, array(
'taxonomy' => 'wptests_tax',
) );
@ -191,7 +191,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_post_type( 'wptests_pt2', array( 'has_archive' => false ) );
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = $this->factory->term->create_many( 2, array(
$terms = self::$factory->term->create_many( 2, array(
'taxonomy' => 'wptests_tax',
) );
@ -254,7 +254,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
* @ticket 33460
*/
public function test_hide_title_if_empty_should_be_ignored_when_category_list_is_not_empty() {
$cat = $this->factory->category->create();
$cat = self::$factory->category->create();
$found = wp_list_categories( array(
'echo' => false,
@ -269,9 +269,9 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
* @ticket 12981
*/
public function test_exclude_tree_should_be_respected() {
$c = $this->factory->category->create();
$parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
$child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
$c = self::$factory->category->create();
$parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
$child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
@ -286,11 +286,11 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
* @ticket 12981
*/
public function test_exclude_tree_should_be_merged_with_exclude() {
$c = $this->factory->category->create();
$parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
$child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
$parent2 = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) );
$child2 = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) );
$c = self::$factory->category->create();
$parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
$child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
$parent2 = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) );
$child2 = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) );
$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );

View File

@ -38,7 +38,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertSame( 0, did_action( $error ) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'comment_status' => 'closed',
) );
$data = array(
@ -58,7 +58,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertSame( 0, did_action( $error ) );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
wp_trash_post( $post );
$data = array(
'comment_post_ID' => $post->ID,
@ -77,7 +77,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertSame( 0, did_action( $error ) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'draft',
) );
$data = array(
@ -98,7 +98,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertSame( 0, did_action( $error ) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_date' => date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
) );
@ -121,7 +121,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertSame( 0, did_action( $error ) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_password' => 'password',
) );
$data = array(
@ -142,7 +142,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$_COOKIE['wp-postpass_' . COOKIEHASH] = $hasher->HashPassword( $password );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_password' => $password,
) );
$data = array(
@ -162,13 +162,13 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_submitting_valid_comment_as_logged_in_user_succeeds() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'user_url' => 'http://user.example.org'
) );
wp_set_current_user( $user->ID );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment',
@ -187,7 +187,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_submitting_valid_comment_anonymously_succeeds() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment',
@ -214,7 +214,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
*/
public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment with 1 slash: \\',
@ -236,7 +236,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$error = 'not_logged_in';
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'private',
) );
$data = array(
@ -252,11 +252,11 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_submitting_comment_to_own_private_post_succeeds() {
$user = $this->factory->user->create_and_get();
$user = self::$factory->user->create_and_get();
wp_set_current_user( $user->ID );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'private',
'post_author' => $user->ID,
) );
@ -274,16 +274,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_submitting_comment_to_accessible_private_post_succeeds() {
$author = $this->factory->user->create_and_get( array(
$author = self::$factory->user->create_and_get( array(
'role' => 'author',
) );
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'role' => 'editor',
) );
wp_set_current_user( $user->ID );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'private',
'post_author' => $author->ID,
) );
@ -301,7 +301,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_anonymous_user_cannot_comment_unfiltered_html() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment <script>alert(document.cookie);</script>',
@ -318,14 +318,14 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_unprivileged_user_cannot_comment_unfiltered_html() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'role' => 'author',
) );
wp_set_current_user( $user->ID );
$this->assertFalse( current_user_can( 'unfiltered_html' ) );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment <script>alert(document.cookie);</script>',
@ -340,14 +340,14 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'role' => 'author',
) );
wp_set_current_user( $user->ID );
$this->assertFalse( current_user_can( 'unfiltered_html' ) );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$action = 'unfiltered-html-comment_' . $post->ID;
$nonce = wp_create_nonce( $action );
@ -370,7 +370,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) );
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'role' => 'editor',
) );
@ -384,7 +384,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertTrue( current_user_can( 'unfiltered_html' ) );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$action = 'unfiltered-html-comment_' . $post->ID;
$nonce = wp_create_nonce( $action );
@ -405,7 +405,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'role' => 'editor',
) );
@ -419,7 +419,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$this->assertTrue( current_user_can( 'unfiltered_html' ) );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment <script>alert(document.cookie);</script>',
@ -439,7 +439,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$_comment_registration = get_option( 'comment_registration' );
update_option( 'comment_registration', '1' );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
);
@ -459,7 +459,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$_require_name_email = get_option( 'require_name_email' );
update_option( 'require_name_email', '1' );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment',
@ -481,7 +481,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$_require_name_email = get_option( 'require_name_email' );
update_option( 'require_name_email', '1' );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment',
@ -503,7 +503,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$_require_name_email = get_option( 'require_name_email' );
update_option( 'require_name_email', '1' );
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => 'Comment',
@ -523,7 +523,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$error = 'require_valid_comment';
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = array(
'comment_post_ID' => $post->ID,
'comment' => '',

View File

@ -21,9 +21,9 @@ class Tests_Comment extends WP_UnitTestCase {
}
function test_wp_update_comment() {
$post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
$post2 = $this->factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) );
$comments = $this->factory->comment->create_post_comments( $post->ID, 5 );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
$post2 = self::$factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) );
$comments = self::$factory->comment->create_post_comments( $post->ID, 5 );
$result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
$this->assertEquals( 1, $result );
$comment = get_comment( $comments[0] );
@ -39,7 +39,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 30627
*/
function test_wp_update_comment_updates_comment_type() {
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) );
@ -51,7 +51,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 30307
*/
function test_wp_update_comment_updates_user_id() {
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1 ) );
@ -60,25 +60,25 @@ class Tests_Comment extends WP_UnitTestCase {
}
public function test_get_approved_comments() {
$ca1 = $this->factory->comment->create( array(
$ca1 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
) );
$ca2 = $this->factory->comment->create( array(
$ca2 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
) );
$ca3 = $this->factory->comment->create( array(
$ca3 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '0'
) );
$c2 = $this->factory->comment->create( array(
$c2 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback'
) );
$c3 = $this->factory->comment->create( array(
$c3 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback'
) );
$c4 = $this->factory->comment->create( array(
$c4 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario'
) );
$c5 = $this->factory->comment->create( array(
$c5 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi'
) );
@ -92,7 +92,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 30412
*/
public function test_get_approved_comments_with_post_id_0_should_return_empty_array() {
$ca1 = $this->factory->comment->create( array(
$ca1 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
) );
@ -256,11 +256,11 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 32566
*/
public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_author' => 0,
) );
$c = $this->factory->comment->create( array(
$c = self::$factory->comment->create( array(
'comment_post_ID' => $p,
) );
@ -271,7 +271,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 33587
*/
public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() {
$c = $this->factory->comment->create( array(
$c = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => 'spam',
) );
@ -284,7 +284,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 12431
*/
public function test_wp_new_comment_with_meta() {
$c = $this->factory->comment->create( array(
$c = self::$factory->comment->create( array(
'comment_approved' => '1',
'comment_meta' => array(
'food' => 'taco',
@ -299,35 +299,35 @@ class Tests_Comment extends WP_UnitTestCase {
* @ticket 8071
*/
public function test_wp_comment_get_children_should_fill_children() {
$c1 = $this->factory->comment->create( array(
$c1 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
) );
$c2 = $this->factory->comment->create( array(
$c2 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
$c3 = $this->factory->comment->create( array(
$c3 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c2,
) );
$c4 = $this->factory->comment->create( array(
$c4 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c1,
) );
$c5 = $this->factory->comment->create( array(
$c5 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
) );
$c6 = $this->factory->comment->create( array(
$c6 = self::$factory->comment->create( array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_parent' => $c5,
@ -347,7 +347,7 @@ class Tests_Comment extends WP_UnitTestCase {
* @group 27571
*/
public function test_post_properties_should_be_lazyloaded() {
$c = $this->factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
$c = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
$post = get_post( self::$post_id );
$comment = get_comment( $c );

View File

@ -31,7 +31,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase {
}
public function test_should_return_true_when_comment_whitelist_is_enabled_and_author_has_approved_comment() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$prev_args = array(
'comment_post_ID' => $post_id,
'comment_content' => 'Can we build it?',
@ -39,7 +39,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase {
'comment_author_email' => 'bob@example.com',
'comment_author' => 'BobtheBuilder',
);
$prev_comment_id = $this->factory->comment->create( $prev_args );
$prev_comment_id = self::$factory->comment->create( $prev_args );
update_option( 'comment_whitelist', 1 );

View File

@ -5,7 +5,7 @@
*/
class Tests_Comment_CommentForm extends WP_UnitTestCase {
public function test_default_markup_for_submit_button_and_wrapper() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$args = array(
'name_submit' => 'foo-name',
@ -21,7 +21,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase {
}
public function test_custom_submit_button() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$args = array(
'name_submit' => 'foo-name',
@ -37,7 +37,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase {
}
public function test_custom_submit_field() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$args = array(
'name_submit' => 'foo-name',
@ -57,7 +57,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase {
* @ticket 32312
*/
public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$args = array(
'name_submit' => 'foo-name',

View File

@ -12,13 +12,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
@ -42,13 +42,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
@ -72,13 +72,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
@ -102,13 +102,13 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
@ -132,33 +132,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest_on_subsequent_pages() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
) );
$comment_5 = $this->factory->comment->create( array(
$comment_5 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
) );
$comment_6 = $this->factory->comment->create( array(
$comment_6 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
@ -187,33 +187,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
) );
$comment_5 = $this->factory->comment->create( array(
$comment_5 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
) );
$comment_6 = $this->factory->comment->create( array(
$comment_6 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
@ -242,23 +242,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
@ -287,23 +287,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest_on_subsequent_pages() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
@ -334,18 +334,18 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_last_page_of_comments_should_be_full_when_default_comment_page_is_newest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
@ -376,18 +376,18 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_first_page_of_comments_should_have_remainder_when_default_comments_page_is_newest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
@ -416,23 +416,23 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_oldest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
@ -480,33 +480,33 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
*/
public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_newest() {
$now = time();
$p = $this->factory->post->create();
$comment_1 = $this->factory->comment->create( array(
$p = self::$factory->post->create();
$comment_1 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$comment_2 = $this->factory->comment->create( array(
$comment_2 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$comment_3 = $this->factory->comment->create( array(
$comment_3 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$comment_4 = $this->factory->comment->create( array(
$comment_4 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
) );
$comment_5 = $this->factory->comment->create( array(
$comment_5 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
) );
$comment_6 = $this->factory->comment->create( array(
$comment_6 = self::$factory->comment->create( array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),

View File

@ -22,7 +22,7 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase {
// Just some dummy posts to use as parents for comments
for ( $i = 1; $i <= 2; $i++ ) {
$this->posts[$i] = $this->factory->post->create();
$this->posts[$i] = self::$factory->post->create();
}
// Be careful modifying this. Tests are coded to expect this exact sample data.
@ -39,7 +39,7 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase {
);
foreach ( $comment_dates as $comment_date => $comment_parent ) {
$result = $this->factory->comment->create( array(
$result = self::$factory->comment->create( array(
'comment_date' => $comment_date,
'comment_post_ID' => $this->posts[ $comment_parent ],
) );

View File

@ -5,32 +5,32 @@
*/
class Tests_Comment_GetCommentClass extends WP_UnitTestCase {
public function test_should_accept_comment_id() {
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$post_id = self::$factory->post->create();
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$classes = get_comment_class( '', $comment_id );
$this->assertContains( 'comment', $classes );
}
public function test_should_accept_comment_object() {
$post_id = $this->factory->post->create();
$comment = $this->factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
$post_id = self::$factory->post->create();
$comment = self::$factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
$classes = get_comment_class( '', $comment );
$this->assertContains( 'comment', $classes );
}
public function test_should_append_single_class() {
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$post_id = self::$factory->post->create();
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$classes = get_comment_class( 'foo', $comment_id );
$this->assertContains( 'foo', $classes );
}
public function test_should_append_array_of_classes() {
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$post_id = self::$factory->post->create();
$comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$classes = get_comment_class( array( 'foo', 'bar' ), $comment_id );
$this->assertContains( 'foo', $classes );

View File

@ -14,7 +14,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
}
public function test_get_comment_count_approved() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 1
) );
@ -29,7 +29,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
}
public function test_get_comment_count_awaiting() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 0
) );
@ -44,7 +44,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
}
public function test_get_comment_count_spam() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'spam'
) );
@ -59,7 +59,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
}
public function test_get_comment_count_trash() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'trash'
) );
@ -74,7 +74,7 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
}
public function test_get_comment_count_post_trashed() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'post-trashed'
) );

View File

@ -14,7 +14,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco
}
public function test_get_comment_excerpt() {
$comment_id = $this->factory->comment->create( array(
$comment_id = self::$factory->comment->create( array(
'comment_content' => self::$bacon_comment
) );
@ -24,7 +24,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco
}
public function test_get_comment_excerpt_filtered() {
$comment_id = $this->factory->comment->create( array(
$comment_id = self::$factory->comment->create( array(
'comment_content' => self::$bacon_comment
) );

View File

@ -11,33 +11,33 @@ class Tests_Comment_GetCommentLink extends WP_UnitTestCase {
parent::setUp();
$now = time();
$this->p = $this->factory->post->create();
$this->comments[] = $this->factory->comment->create( array(
$this->p = self::$factory->post->create();
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
) );
$this->comments[] = $this->factory->comment->create( array(
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
) );
$this->comments[] = $this->factory->comment->create( array(
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
) );
$this->comments[] = $this->factory->comment->create( array(
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
) );
$this->comments[] = $this->factory->comment->create( array(
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
) );
$this->comments[] = $this->factory->comment->create( array(
$this->comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $this->p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),

View File

@ -38,7 +38,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
*/
function test_empty() {
//setup post and comments
$post_id = $this->factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$this->go_to( '/?p=' . $post_id );
global $wp_query;
@ -60,9 +60,9 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
*/
function test_threaded_comments( ) {
//setup post and comments
$post = $this->factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$comments = $this->factory->comment->create_post_comments( $post->ID, 15 );
$this->factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$comments = self::$factory->comment->create_post_comments( $post->ID, 15 );
self::$factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) );
$comments = get_comments( array( 'post_id' => $post->ID ) );
$this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) );
@ -76,9 +76,9 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
function test_option_thread_comments() {
//setup post and comments
$post = $this->factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$comments = $this->factory->comment->create_post_comments( $post->ID, 15 );
$this->factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
$comments = self::$factory->comment->create_post_comments( $post->ID, 15 );
self::$factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) );
$comments = get_comments( array( 'post_id' => $post->ID ) );
update_option( 'thread_comments', false );
@ -104,8 +104,8 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
update_option( 'posts_per_rss', 100 );
$post = $this->factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) );
$comments = $this->factory->comment->create_post_comments( $post->ID, 25 );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) );
$comments = self::$factory->comment->create_post_comments( $post->ID, 25 );
$wp_query = new WP_Query( array( 'p' => $post->ID, 'comments_per_page' => 10, 'feed' =>'comments-' ) );

View File

@ -7,26 +7,26 @@
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_last_comment() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
// page 4
$comment_last = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) );
$comment_last = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) );
// page 3
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) );
// page 2
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) );
// page 1
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) );
$this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );
$comment_first = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) );
self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );
$comment_first = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );
$this->assertEquals( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) );
$this->assertEquals( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 10 ) ) );
@ -36,18 +36,18 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
}
public function test_type_pings() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$now = time();
$trackbacks = array();
for ( $i = 0; $i <= 3; $i++ ) {
$trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$now -= 10 * $i;
}
$pingbacks = array();
for ( $i = 0; $i <= 6; $i++ ) {
$pingbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$pingbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$now -= 10 * $i;
}
@ -62,8 +62,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_subsequent_calls_should_hit_cache() {
global $wpdb;
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
// Prime cache.
$page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
@ -81,13 +81,13 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_cache_hits_should_be_sensitive_to_comment_type() {
global $wpdb;
$p = $this->factory->post->create();
$comment = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) );
$p = self::$factory->post->create();
$comment = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) );
$now = time();
$trackbacks = array();
for ( $i = 0; $i <= 5; $i++ ) {
$trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) );
$trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) );
}
// Prime cache for trackbacks.
@ -105,8 +105,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
* @ticket 11334
*/
public function test_cache_should_be_invalidated_when_comment_is_approved() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) );
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) );
// Prime cache.
$page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
@ -121,8 +121,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
* @ticket 11334
*/
public function test_cache_should_be_invalidated_when_comment_is_deleted() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
// Prime cache.
$page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
@ -137,8 +137,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
* @ticket 11334
*/
public function test_cache_should_be_invalidated_when_comment_is_spammed() {
$p = $this->factory->post->create();
$c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );
$p = self::$factory->post->create();
$c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
// Prime cache.
$page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
@ -155,10 +155,10 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_cache_should_be_invalidated_when_older_comment_is_published() {
$now = time();
$p = $this->factory->post->create();
$c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
$c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
$p = self::$factory->post->create();
$c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
$c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
$this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
@ -171,13 +171,13 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
* @ticket 34057
*/
public function test_query_should_be_limited_to_comments_on_the_proper_post() {
$posts = $this->factory->post->create_many( 2 );
$posts = self::$factory->post->create_many( 2 );
$now = time();
$comments_0 = $comments_1 = array();
for ( $i = 0; $i < 5; $i++ ) {
$comments_0[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$comments_1[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$comments_0[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$comments_1[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
}
$found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) );
@ -191,15 +191,15 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
* @ticket 13939
*/
public function test_only_top_level_comments_should_be_included_in_older_count() {
$post = $this->factory->post->create();
$post = self::$factory->post->create();
$now = time();
$comment_parents = $comment_children = array();
for ( $i = 0; $i < 5; $i++ ) {
$parent = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$parent = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$comment_parents[ $i ] = $parent;
$child = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );
$child = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );
$comment_children[ $i ] = $child;
}
@ -228,10 +228,10 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_comments_per_page_option_should_be_fallback_when_query_var_is_not_available() {
$now = time();
$p = $this->factory->post->create();
$c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
$c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
$p = self::$factory->post->create();
$c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
$c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
$c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
update_option( 'comments_per_page', 2 );

View File

@ -10,8 +10,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_update_comment_meta_cache_should_default_to_true() {
global $wpdb;
$p = $this->factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = $this->factory->comment->create_post_comments( $p, 3 );
$p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
foreach ( $comment_ids as $cid ) {
update_comment_meta( $cid, 'foo', 'bar' );
@ -38,8 +38,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_update_comment_meta_cache_true() {
global $wpdb;
$p = $this->factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = $this->factory->comment->create_post_comments( $p, 3 );
$p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
foreach ( $comment_ids as $cid ) {
update_comment_meta( $cid, 'foo', 'bar' );
@ -67,8 +67,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_update_comment_meta_cache_false() {
global $wpdb;
$p = $this->factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = $this->factory->comment->create_post_comments( $p, 3 );
$p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
foreach ( $comment_ids as $cid ) {
update_comment_meta( $cid, 'foo', 'bar' );
@ -93,8 +93,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() {
global $wpdb;
$p = $this->factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = $this->factory->comment->create_post_comments( $p, 3 );
$p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
$comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
foreach ( $comment_ids as $cid ) {
update_comment_meta( $cid, 'sauce', 'fire' );
@ -128,12 +128,12 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() {
global $wpdb;
$posts = $this->factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
$posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
$now = time();
$comments = array();
for ( $i = 0; $i < 5; $i++ ) {
$comments[] = $this->factory->comment->create( array(
$comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $posts[0],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
) );
@ -172,12 +172,12 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() {
global $wpdb;
$posts = $this->factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
$posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
$now = time();
$comments = array();
for ( $i = 0; $i < 5; $i++ ) {
$comments[] = $this->factory->comment->create( array(
$comments[] = self::$factory->comment->create( array(
'comment_post_ID' => $posts[0],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
) );

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
// we need an admin user to bypass comment flood protection
$this->author_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
$this->old_current_user = get_current_user_id();
wp_set_current_user( $this->author_id );
@ -34,7 +34,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
*
*/
function test_wp_new_comment() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
// not testing comment_author_email or comment_author_url
// as slashes are not permitted in that data
@ -74,8 +74,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
*
*/
function test_edit_comment() {
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create(array(
$post_id = self::$factory->post->create();
$comment_id = self::$factory->comment->create(array(
'comment_post_ID' => $post_id
));
@ -117,7 +117,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
*
*/
function test_wp_insert_comment() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$comment_id = wp_insert_comment(array(
'comment_post_ID' => $post_id,
@ -145,8 +145,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
*
*/
function test_wp_update_comment() {
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create(array(
$post_id = self::$factory->post->create();
$comment_id = self::$factory->comment->create(array(
'comment_post_ID' => $post_id
));

View File

@ -5,26 +5,26 @@
class Tests_Comment_Template extends WP_UnitTestCase {
function test_get_comments_number() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->assertEquals( 0, get_comments_number( 0 ) );
$this->assertEquals( 0, get_comments_number( $post_id ) );
$this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) );
$this->factory->comment->create_post_comments( $post_id, 12 );
self::$factory->comment->create_post_comments( $post_id, 12 );
$this->assertEquals( 12, get_comments_number( $post_id ) );
$this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) );
}
function test_get_comments_number_without_arg() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$permalink = get_permalink( $post_id );
$this->go_to( $permalink );
$this->assertEquals( 0, get_comments_number() );
$this->factory->comment->create_post_comments( $post_id, 12 );
self::$factory->comment->create_post_comments( $post_id, 12 );
$this->go_to( $permalink );
$this->assertEquals( 12, get_comments_number() );

View File

@ -8,15 +8,15 @@ class Tests_Comment_Walker extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->post_id = $this->factory->post->create();
$this->post_id = self::$factory->post->create();
}
/**
* @ticket 14041
*/
function test_has_children() {
$comment_parent = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
$comment_child = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) );
$comment_parent = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
$comment_child = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) );
$comment_parent = get_comment( $comment_parent );
$comment_child = get_comment( $comment_child );

View File

@ -15,7 +15,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_approved() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 1
) );
@ -31,7 +31,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_awaiting() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 0
) );
@ -47,7 +47,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_spam() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'spam'
) );
@ -63,7 +63,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_trash() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'trash'
) );
@ -79,7 +79,7 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_post_trashed() {
$this->factory->comment->create( array(
self::$factory->comment->create( array(
'comment_approved' => 'post-trashed'
) );
@ -95,10 +95,10 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
}
public function test_wp_count_comments_cache() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_status' => 'publish'
) );
$comment_id = $this->factory->comment->create( array(
$comment_id = self::$factory->comment->create( array(
'comment_approved' => '1',
'comment_post_ID' => $post_id
) );

View File

@ -251,10 +251,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
* @see WP_Customize_Manager::set_return_url()
*/
function test_return_url() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'author' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'author' ) ) );
$this->assertEquals( get_admin_url(), $this->manager->get_return_url() );
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$this->assertTrue( current_user_can( 'edit_theme_options' ) );
$this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() );
@ -301,7 +301,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
* @see WP_Customize_Manager::customize_pane_settings()
*/
function test_customize_pane_settings() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$this->manager->register_controls();
$this->manager->prepare_controls();
$autofocus = array( 'control' => 'blogname' );

View File

@ -21,7 +21,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function setUp() {
parent::setUp();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
@ -149,7 +149,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_value_type_post_type() {
do_action( 'customize_register', $this->wp_customize );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$menu_id = wp_create_nav_menu( 'Menu' );
$item_title = 'Greetings';
@ -192,7 +192,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_value_type_taxonomy() {
do_action( 'customize_register', $this->wp_customize );
$tax_id = $this->factory->category->create( array( 'name' => 'Salutations' ) );
$tax_id = self::$factory->category->create( array( 'name' => 'Salutations' ) );
$menu_id = wp_create_nav_menu( 'Menu' );
$item_title = 'Greetings';
@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$value = $menu->value();
$this->assertEquals( $post_value, $value );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
@ -296,8 +296,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_preview_updated() {
do_action( 'customize_register', $this->wp_customize );
$first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) );
$first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) );
$primary_menu_id = wp_create_nav_menu( 'Primary' );
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
@ -348,7 +348,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
@ -403,7 +403,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
@ -488,8 +488,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_save_updated() {
do_action( 'customize_register', $this->wp_customize );
$first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) );
$first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) );
$primary_menu_id = wp_create_nav_menu( 'Primary' );
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
@ -554,7 +554,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
@ -623,7 +623,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(

View File

@ -22,7 +22,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
function setUp() {
parent::setUp();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();

View File

@ -22,7 +22,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
function setUp() {
parent::setUp();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
@ -124,7 +124,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
);
// Create pages.
$this->factory->post->create_many( 12, array( 'post_type' => 'page' ) );
self::$factory->post->create_many( 12, array( 'post_type' => 'page' ) );
// Home is included in menu items when page is zero.
$items = $menus->load_available_items_query( 'post_type', 'page', 0 );
@ -145,10 +145,10 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
// Create page.
$post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
// Create pages.
$this->factory->post->create_many( 10 );
self::$factory->post->create_many( 10 );
// Expected menu item array.
$expected = array(
@ -175,7 +175,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
// Create page.
$page_id = $this->factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
$page_id = self::$factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
// Expected menu item array.
$expected = array(
@ -201,7 +201,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
// Create post.
$post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
// Expected menu item array.
$expected = array(
@ -227,7 +227,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
// Create term.
$term_id = $this->factory->category->create( array( 'name' => 'Term Title' ) );
$term_id = self::$factory->category->create( array( 'name' => 'Term Title' ) );
// Expected menu item array.
$expected = array(
@ -279,13 +279,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
// Create posts
$post_ids = array();
$post_ids[] = $this->factory->post->create( array( 'post_title' => 'Search & Test' ) );
$post_ids[] = $this->factory->post->create( array( 'post_title' => 'Some Other Title' ) );
$post_ids[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) );
$post_ids[] = self::$factory->post->create( array( 'post_title' => 'Some Other Title' ) );
// Create terms
$term_ids = array();
$term_ids[] = $this->factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
$term_ids[] = $this->factory->category->create( array( 'name' => 'Cats Drool' ) );
$term_ids[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
$term_ids[] = self::$factory->category->create( array( 'name' => 'Cats Drool' ) );
// Test empty results
$expected = array();
@ -386,7 +386,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
function test_customize_register() {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',

View File

@ -128,7 +128,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::check_capabilities()
*/
function test_check_capabilities() {
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $user_id );
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
@ -154,7 +154,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::maybe_render()
*/
function test_maybe_render() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$panel = new WP_Customize_Panel( $this->manager, 'bar' );
$customize_render_panel_count = did_action( 'customize_render_panel' );
add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) );
@ -179,7 +179,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::print_template()
*/
function test_print_templates_standard() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$panel = new WP_Customize_Panel( $this->manager, 'baz' );
ob_start();
@ -197,7 +197,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::print_template()
*/
function test_print_templates_custom() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$panel = new Custom_Panel_Test( $this->manager, 'baz' );
ob_start();

View File

@ -135,7 +135,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
* @see WP_Customize_Section::check_capabilities()
*/
function test_check_capabilities() {
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $user_id );
$section = new WP_Customize_Section( $this->manager, 'foo' );
@ -161,7 +161,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
* @see WP_Customize_Section::maybe_render()
*/
function test_maybe_render() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$section = new WP_Customize_Section( $this->manager, 'bar' );
$customize_render_section_count = did_action( 'customize_render_section' );
add_action( 'customize_render_section', array( $this, 'action_customize_render_section_test' ) );
@ -186,7 +186,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
* @see WP_Customize_Section::print_template()
*/
function test_print_templates_standard() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$section = new WP_Customize_Section( $this->manager, 'baz' );
ob_start();
@ -201,7 +201,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
* @see WP_Customize_Section::print_template()
*/
function test_print_templates_custom() {
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$section = new Custom_Section_Test( $this->manager, 'baz' );
ob_start();

View File

@ -394,7 +394,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->assertTrue( 0 === did_action( 'customize_save_foo' ) );
// Satisfy all requirements for save to happen.
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
$this->assertTrue( false !== $setting->save() );
$this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
$this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
@ -465,7 +465,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting->preview();
$this->assertTrue( $setting->is_current_blog_previewed() );
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
$this->assertFalse( $setting->is_current_blog_previewed() );
$this->assertNotEquals( $post_value, $setting->value() );

View File

@ -30,7 +30,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $user_id );
}

View File

@ -975,8 +975,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
* @ticket 31001
*/
public function test_validate_date_values_should_process_array_value_for_year() {
$p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) );
$p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = self::$factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) );
$q = new WP_Query( array(
'date_query' => array(
@ -995,8 +995,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
* @ticket 31001
*/
public function test_validate_date_values_should_process_array_value_for_day() {
$p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
$p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
$q = new WP_Query( array(
'date_query' => array(
@ -1016,8 +1016,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
* @expectedIncorrectUsage WP_Date_Query
*/
public function test_validate_date_values_should_process_array_value_for_day_when_values_are_invalid() {
$p1 = $this->factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
$p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
$p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
$q = new WP_Query( array(
'date_query' => array(

View File

@ -509,7 +509,7 @@ class Tests_DB extends WP_UnitTestCase {
$this->markTestSkipped( 'procedure could not be created (missing privileges?)' );
}
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->assertNotEmpty( $wpdb->get_results( 'CALL `test_mysqli_flush_sync_procedure`' ) );
$this->assertNotEmpty( $wpdb->get_results( "SELECT ID FROM `{$wpdb->posts}` LIMIT 1" ) );

View File

@ -9,7 +9,7 @@ class Tests_Formatting_SanitizePost extends WP_UnitTestCase {
* @ticket 22324
*/
function test_int_fields() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$int_fields = array(
'ID' => 'integer',
'post_parent' => 'integer',

View File

@ -9,10 +9,10 @@ class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase {
* @ticket 25349
*/
public function test_secondary_loop_respect_more() {
$post1 = $this->factory->post->create( array(
$post1 = self::$factory->post->create( array(
'post_content' => 'Post 1 Page 1<!--more-->Post 1 Page 2',
) );
$post2 = $this->factory->post->create( array(
$post2 = self::$factory->post->create( array(
'post_content' => 'Post 2 Page 1<!--more-->Post 2 Page 2',
) );
@ -34,10 +34,10 @@ class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase {
* @ticket 25349
*/
public function test_secondary_loop_respect_nextpage() {
$post1 = $this->factory->post->create( array(
$post1 = self::$factory->post->create( array(
'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2',
) );
$post2 = $this->factory->post->create( array(
$post2 = self::$factory->post->create( array(
'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2',
) );

View File

@ -689,7 +689,7 @@ class Tests_Functions extends WP_UnitTestCase {
$actual = ob_get_clean();
$this->assertEquals( '', $actual );
$GLOBALS['post'] = $this->factory->post->create_and_get( array(
$GLOBALS['post'] = self::$factory->post->create_and_get( array(
'post_date' => '2015-09-16 08:00:00'
) );

View File

@ -87,7 +87,7 @@ EOF;
}
function test_wp_get_archives_order() {
$this->factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) );
self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) );
$date_full = date( 'F Y' );
$oct_url = get_month_link( 2012, 10 );
@ -110,7 +110,7 @@ EOF;
function test_wp_get_archives_post_type() {
register_post_type( 'taco', array( 'public' => true ) );
$this->factory->post->create( array(
self::$factory->post->create( array(
'post_type' => 'taco',
'post_author' => '1',
'post_date' => '2014-10-23 19:34:42'

View File

@ -16,7 +16,7 @@ class Tests_General_Archives extends WP_UnitTestCase {
function test_get_archives_cache() {
global $wpdb;
$this->factory->post->create_many( 3, array( 'post_type' => 'post' ) );
self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) );
wp_cache_delete( 'last_changed', 'posts' );
$this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );

View File

@ -34,7 +34,7 @@ class TestFactoryFor extends WP_UnitTestCase {
*/
public function test_term_factory_create_and_get_should_return_term_object() {
register_taxonomy( 'wptests_tax', 'post' );
$term = $this->factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
$term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
$this->assertInternalType( 'object', $term );
$this->assertNotEmpty( $term->term_id );
}

View File

@ -33,8 +33,8 @@ class Tests_Link extends WP_UnitTestCase {
}
function test_wp_get_shortlink() {
$post_id = $this->factory->post->create();
$post_id2 = $this->factory->post->create();
$post_id = self::$factory->post->create();
$post_id2 = self::$factory->post->create();
// Basic case
$this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) );
@ -77,7 +77,7 @@ class Tests_Link extends WP_UnitTestCase {
}
function test_wp_get_shortlink_with_page() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
// Basic case
// Don't test against get_permalink() since it uses ?page_id= for pages.
@ -92,7 +92,7 @@ class Tests_Link extends WP_UnitTestCase {
* @ticket 26871
*/
function test_wp_get_shortlink_with_home_page() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $post_id );
@ -108,22 +108,22 @@ class Tests_Link extends WP_UnitTestCase {
*/
function test_get_adjacent_post() {
// Need some sample posts to test adjacency
$post_one = $this->factory->post->create_and_get( array(
$post_one = self::$factory->post->create_and_get( array(
'post_title' => 'First',
'post_date' => '2012-01-01 12:00:00'
) );
$post_two = $this->factory->post->create_and_get( array(
$post_two = self::$factory->post->create_and_get( array(
'post_title' => 'Second',
'post_date' => '2012-02-01 12:00:00'
) );
$post_three = $this->factory->post->create_and_get( array(
$post_three = self::$factory->post->create_and_get( array(
'post_title' => 'Third',
'post_date' => '2012-03-01 12:00:00'
) );
$post_four = $this->factory->post->create_and_get( array(
$post_four = self::$factory->post->create_and_get( array(
'post_title' => 'Fourth',
'post_date' => '2012-04-01 12:00:00'
) );
@ -183,33 +183,33 @@ class Tests_Link extends WP_UnitTestCase {
global $wpdb;
$wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) );
$include = $this->factory->term->create( array(
$include = self::$factory->term->create( array(
'taxonomy' => 'category',
'name' => 'Include',
) );
$exclude = $this->factory->category->create();
$exclude = self::$factory->category->create();
$one = $this->factory->post->create_and_get( array(
$one = self::$factory->post->create_and_get( array(
'post_date' => '2012-01-01 12:00:00',
'post_category' => array( $include, $exclude ),
) );
$two = $this->factory->post->create_and_get( array(
$two = self::$factory->post->create_and_get( array(
'post_date' => '2012-01-02 12:00:00',
'post_category' => array(),
) );
$three = $this->factory->post->create_and_get( array(
$three = self::$factory->post->create_and_get( array(
'post_date' => '2012-01-03 12:00:00',
'post_category' => array( $include, $exclude ),
) );
$four = $this->factory->post->create_and_get( array(
$four = self::$factory->post->create_and_get( array(
'post_date' => '2012-01-04 12:00:00',
'post_category' => array( $include ),
) );
$five = $this->factory->post->create_and_get( array(
$five = self::$factory->post->create_and_get( array(
'post_date' => '2012-01-05 12:00:00',
'post_category' => array( $include, $exclude ),
) );
@ -249,13 +249,13 @@ class Tests_Link extends WP_UnitTestCase {
public function test_get_adjacent_post_excluded_terms() {
register_taxonomy( 'wptests_tax', 'post' );
$t = $this->factory->term->create( array(
$t = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
$p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
$p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
$p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
$p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
wp_set_post_terms( $p2, array( $t ), 'wptests_tax' );
@ -281,13 +281,13 @@ class Tests_Link extends WP_UnitTestCase {
public function test_get_adjacent_post_excluded_terms_should_not_require_posts_to_have_terms_in_any_taxonomy() {
register_taxonomy( 'wptests_tax', 'post' );
$t = $this->factory->term->create( array(
$t = self::$factory->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
$p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
$p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
$p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
$p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
wp_set_post_terms( $p2, array( $t ), 'wptests_tax' );
@ -348,7 +348,7 @@ class Tests_Link extends WP_UnitTestCase {
flush_rewrite_rules();
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_status' => 'publish',
'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
) );
@ -368,7 +368,7 @@ class Tests_Link extends WP_UnitTestCase {
flush_rewrite_rules();
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_status' => 'future',
'post_type' => 'wptests_pt',
'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
@ -388,7 +388,7 @@ class Tests_Link extends WP_UnitTestCase {
public function test_unattached_attachment_has_a_pretty_permalink() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'An Attachment!',
@ -412,9 +412,9 @@ class Tests_Link extends WP_UnitTestCase {
flush_rewrite_rules();
$post_id = $this->factory->post->create( array( 'post_type' => 'not_a_post_type' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'not_a_post_type' ) );
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'An Attachment!',

View File

@ -10,13 +10,13 @@ class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase {
public function setUp(){
parent::setUp();
$this->cat_id = $this->factory->category->create( array( 'name' => 'other' ) );
$this->cat_id = self::$factory->category->create( array( 'name' => 'other' ) );
$this->post_ids = array();
$this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );
$this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );
$this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );
$this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );
$this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );
$this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );
$this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );
$this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );
$this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );
$this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );
//set current post (has 2 on each end)
global $GLOBALS;
@ -25,37 +25,43 @@ class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase {
public function test_get_next_post_link_default() {
$actual = get_next_post_link();
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> &raquo;';
$title = get_post( $this->post_ids[1] )->post_title;
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
$this->assertSame( $expected, $actual );
}
public function test_get_previous_post_link_default() {
$actual = get_previous_post_link();
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>';
$title = get_post( $this->post_ids[3] )->post_title;
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
$this->assertSame( $expected, $actual );
}
public function test_get_next_post_link_same_category() {
$actual = get_next_post_link( '%link &raquo;', '%title', true );
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> &raquo;';
$title = get_post( $this->post_ids[1] )->post_title;
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
$this->assertSame( $expected, $actual );
}
public function test_get_previous_post_link_same_category() {
$actual = get_previous_post_link( '&laquo; %link', '%title', true );
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>';
$title = get_post( $this->post_ids[3] )->post_title;
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
$this->assertSame( $expected, $actual );
}
public function test_get_next_post_link_exclude_category() {
$actual = get_next_post_link( '%link &raquo;', '%title', false, $this->cat_id );
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> &raquo;';
$title = get_post( $this->post_ids[1] )->post_title;
$expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
$this->assertSame( $expected, $actual );
}
public function test_get_previous_post_link_exclude_category() {
$actual = get_previous_post_link( '&laquo; %link', '%title', false, $this->cat_id );
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>';
$title = get_post( $this->post_ids[3] )->post_title;
$expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
$this->assertSame( $expected, $actual );
}
}

View File

@ -8,7 +8,7 @@
class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase {
public function test_page_should_respect_value_of_cpage_query_var() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$this->go_to( get_permalink( $p ) );
$cpage = get_query_var( 'cpage' );
@ -25,7 +25,7 @@ class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase {
* @ticket 20319
*/
public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$this->go_to( get_permalink( $p ) );
$cpage = get_query_var( 'cpage' );

View File

@ -5,7 +5,7 @@
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_post_link() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$link = get_post_comments_feed_link( $post_id );
$expected = add_query_arg( array(
@ -19,7 +19,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_post_pretty_link() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$link = get_post_comments_feed_link( $post_id );
$expected = get_permalink( $post_id ) . 'feed/';
@ -28,8 +28,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
}
public function test_attachment_link() {
$post_id = $this->factory->post->create();
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
$post_id = self::$factory->post->create();
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -46,10 +46,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_attachment_pretty_link() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_status' => 'publish'
) );
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'Burrito'
@ -66,8 +66,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_attachment_no_name_pretty_link() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$post_id = $this->factory->post->create();
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
$post_id = self::$factory->post->create();
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -79,7 +79,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
}
public function test_unattached_link() {
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -96,7 +96,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_unattached_pretty_link() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
$attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );

View File

@ -8,7 +8,7 @@
class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase {
public function test_page_should_respect_value_of_cpage_query_var() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$this->go_to( get_permalink( $p ) );
$cpage = get_query_var( 'cpage' );
@ -22,7 +22,7 @@ class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase {
}
public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
$p = $this->factory->post->create();
$p = self::$factory->post->create();
$this->go_to( get_permalink( $p ) );
$cpage = get_query_var( 'cpage' );

View File

@ -236,8 +236,8 @@ EOF;
* @ticket 22960
*/
function test_get_attached_images() {
$post_id = $this->factory->post->create();
$attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array(
$post_id = self::$factory->post->create();
$attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -253,7 +253,7 @@ EOF;
$ids1 = array();
$ids1_srcs = array();
foreach ( range( 1, 3 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
$attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -266,7 +266,7 @@ EOF;
$ids2 = array();
$ids2_srcs = array();
foreach ( range( 4, 6 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
$attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -284,7 +284,7 @@ EOF;
[gallery ids="$ids2_joined"]
BLOB;
$post_id = $this->factory->post->create( array( 'post_content' => $blob ) );
$post_id = self::$factory->post->create( array( 'post_content' => $blob ) );
$srcs = get_post_galleries_images( $post_id );
$this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) );
}
@ -296,7 +296,7 @@ BLOB;
$ids1 = array();
$ids1_srcs = array();
foreach ( range( 1, 3 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
$attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -309,7 +309,7 @@ BLOB;
$ids2 = array();
$ids2_srcs = array();
foreach ( range( 4, 6 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
$attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
@ -327,7 +327,7 @@ BLOB;
[gallery ids="$ids2_joined"]
BLOB;
$post_id = $this->factory->post->create( array( 'post_content' => $blob ) );
$post_id = self::$factory->post->create( array( 'post_content' => $blob ) );
$srcs = get_post_gallery_images( $post_id );
$this->assertEquals( $srcs, $ids1_srcs );
}
@ -505,7 +505,7 @@ VIDEO;
*/
function test_attachment_url_to_postid() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
$attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
) );
@ -516,7 +516,7 @@ VIDEO;
function test_attachment_url_to_postid_schemes() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
$attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
) );
@ -530,7 +530,7 @@ VIDEO;
function test_attachment_url_to_postid_filtered() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
$attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
) );
@ -704,8 +704,8 @@ EOF;
function test_wp_get_attachment_image_url() {
$this->assertFalse( wp_get_attachment_image_url( 0 ) );
$post_id = $this->factory->post->create();
$attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array(
$post_id = self::$factory->post->create();
$attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
) );
@ -760,7 +760,7 @@ EOF;
// Make an image.
$filename = DIR_TESTDATA . '/images/test-image-large.png';
$id = $this->factory->attachment->create_upload_object( $filename );
$id = self::$factory->attachment->create_upload_object( $filename );
$image = wp_get_attachment_metadata( $id );

View File

@ -8,7 +8,7 @@ class Tests_Meta extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) );
$this->author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
$this->meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value' );
$this->delete_meta_id = add_metadata( 'user', $this->author->ID, 'delete_meta_key', 'delete_meta_value' );
}
@ -194,10 +194,10 @@ class Tests_Meta extends WP_UnitTestCase {
* @ticket 16814
*/
function test_meta_type_cast() {
$post_id1 = $this->factory->post->create();
$post_id1 = self::$factory->post->create();
add_post_meta( $post_id1, 'num_as_longtext', 123 );
add_post_meta( $post_id1, 'num_as_longtext_desc', 10 );
$post_id2 = $this->factory->post->create();
$post_id2 = self::$factory->post->create();
add_post_meta( $post_id2, 'num_as_longtext', 99 );
add_post_meta( $post_id2, 'num_as_longtext_desc', 100 );
@ -258,7 +258,7 @@ class Tests_Meta extends WP_UnitTestCase {
}
function test_meta_cache_order_asc() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$colors = array( 'red', 'blue', 'yellow', 'green' );
foreach ( $colors as $color )
add_post_meta( $post_id, 'color', $color );

View File

@ -8,8 +8,8 @@
class Tests_Meta_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$this->post_id = $this->factory->post->create();
$this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
$this->post_id = self::$factory->post->create();
$this->old_current_user = get_current_user_id();
wp_set_current_user( $this->author_id );
@ -32,7 +32,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_edit_post() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
if ( function_exists( 'wp_add_post_meta' ) ) {
$meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' );
$meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' );
@ -108,7 +108,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_add_post_meta() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
@ -123,7 +123,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_update_post_meta() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
@ -141,7 +141,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
if ( !function_exists( 'wp_add_post_meta' ) ) {
return;
}
$id = $this->factory->post->create();
$id = self::$factory->post->create();
wp_add_post_meta( $id, 'slash_test_1', $this->slash_1 );
wp_add_post_meta( $id, 'slash_test_2', $this->slash_3 );
wp_add_post_meta( $id, 'slash_test_3', $this->slash_4 );
@ -159,7 +159,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
if ( !function_exists( 'wp_update_post_meta' ) ) {
return;
}
$id = $this->factory->post->create();
$id = self::$factory->post->create();
wp_update_post_meta( $id, 'slash_test_1', $this->slash_1 );
wp_update_post_meta( $id, 'slash_test_2', $this->slash_3 );
wp_update_post_meta( $id, 'slash_test_3', $this->slash_4 );
@ -174,7 +174,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_add_comment_meta() {
$id = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
$id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
add_comment_meta( $id, 'slash_test_1', $this->slash_1 );
add_comment_meta( $id, 'slash_test_2', $this->slash_3 );
@ -198,7 +198,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_update_comment_meta() {
$id = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
$id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
add_comment_meta( $id, 'slash_test_1', 'foo' );
add_comment_meta( $id, 'slash_test_2', 'foo' );
@ -226,7 +226,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_add_user_meta() {
$id = $this->factory->user->create();
$id = self::$factory->user->create();
add_user_meta( $id, 'slash_test_1', $this->slash_1 );
add_user_meta( $id, 'slash_test_2', $this->slash_3 );
@ -250,7 +250,7 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
*
*/
function test_update_user_meta() {
$id = $this->factory->user->create();
$id = self::$factory->user->create();
add_user_meta( $id, 'slash_test_1', 'foo' );
add_user_meta( $id, 'slash_test_2', 'foo' );

View File

@ -40,7 +40,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
);
foreach ( $ids as &$id ) {
$id = $this->factory->network->create( $id );
$id = self::$factory->network->create( $id );
}
unset( $id );
@ -88,7 +88,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
);
foreach ( $ids as &$id ) {
$id = $this->factory->blog->create( $id );
$id = self::$factory->blog->create( $id );
}
unset( $id );
@ -169,7 +169,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
);
foreach ( $network_ids as &$id ) {
$id = $this->factory->network->create( $id );
$id = self::$factory->network->create( $id );
}
unset( $id );
@ -182,7 +182,7 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
);
foreach ( $ids as &$id ) {
$id = $this->factory->blog->create( $id );
$id = self::$factory->blog->create( $id );
}
unset( $id );

View File

@ -22,7 +22,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
}
function test_get_space_used_switched_site() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
// Our comparison of space relies on an initial value of 0. If a previous test has failed or if the
@ -30,7 +30,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
// will be polluted. We create sites until an empty one is available.
while ( 0 != get_space_used() ) {
restore_current_blog();
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
}
@ -58,7 +58,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
function test_get_space_used_main_site() {
$space_used = get_space_used();
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
// We don't rely on an initial value of 0 for space used, but should have a clean space available
@ -66,7 +66,7 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
// existing content directories in src.
while ( 0 != get_space_used() ) {
restore_current_blog();
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
}

View File

@ -37,8 +37,8 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase {
$site = get_current_site();
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
$user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
$blog_id2 = self::$factory->blog->create( array( 'user_id' => $user_id ) );
$info = wp_upload_dir();
$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
@ -67,7 +67,7 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase {
// Upload a file to the main site on the network.
$file1 = wp_upload_bits( $filename, null, $contents );
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
$file2 = wp_upload_bits( $filename, null, $contents );

View File

@ -37,7 +37,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
* as the main network ID.
*/
function test_get_main_network_id_two_networks() {
$this->factory->network->create();
self::$factory->network->create();
$this->assertEquals( 1, get_main_network_id() );
}
@ -49,7 +49,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
function test_get_main_network_id_after_network_switch() {
global $current_site;
$id = $this->factory->network->create();
$id = self::$factory->network->create();
$current_site->id = (int) $id;
@ -65,7 +65,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
*/
function test_get_main_network_id_after_network_delete() {
global $wpdb, $current_site;
$id = $this->factory->network->create();
$id = self::$factory->network->create();
$current_site->id = (int) $id;
$wpdb->query( "UPDATE {$wpdb->site} SET id=100 WHERE id=1" );
@ -90,13 +90,13 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
$site_count_start = get_blog_count();
// false for large networks by default
add_filter( 'enable_live_network_counts', '__return_false' );
$this->factory->blog->create_many( 4 );
self::$factory->blog->create_many( 4 );
// count only updated when cron runs, so unchanged
$this->assertEquals( $site_count_start, (int) get_blog_count() );
add_filter( 'enable_live_network_counts', '__return_true' );
$site_ids = $this->factory->blog->create_many( 4 );
$site_ids = self::$factory->blog->create_many( 4 );
$this->assertEquals( $site_count_start + 9, (int) get_blog_count() );
@ -211,7 +211,7 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
// Only false for large networks as of 3.7
add_filter( 'enable_live_network_counts', '__return_false' );
$this->factory->user->create( array( 'role' => 'administrator' ) );
self::$factory->user->create( array( 'role' => 'administrator' ) );
$count = get_user_count(); // No change, cache not refreshed
$this->assertEquals( $start_count, $count );
@ -240,8 +240,8 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
$dashboard_blog = get_dashboard_blog();
$this->assertEquals( 1, $dashboard_blog->blog_id );
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) );
$user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
$blog_id = self::$factory->blog->create( array( 'user_id' => $user_id ) );
$this->assertInternalType( 'int', $blog_id );
// set the dashboard blog to another one

View File

@ -34,7 +34,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' );
$this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$cap_key = wp_get_current_user()->cap_key;
switch_to_blog( $blog_id );
@ -74,7 +74,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
function test_created_site_details() {
global $wpdb;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$this->assertInternalType( 'int', $blog_id );
$prefix = $wpdb->get_blog_prefix( $blog_id );
@ -130,7 +130,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* When a site is flagged as 'deleted', its data should be cleared from cache.
*/
function test_data_in_cache_after_wpmu_delete_blog_drop_false() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$details = get_blog_details( $blog_id, false );
$key = md5( $details->domain . $details->path );
@ -151,7 +151,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
function test_data_in_tables_after_wpmu_delete_blog_drop_false() {
global $wpdb;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
// Delete the site without forcing a table drop.
wpmu_delete_blog( $blog_id, false );
@ -169,7 +169,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* When a site is fully deleted, its data should be cleared from cache.
*/
function test_data_in_cache_after_wpmu_delete_blog_drop_true() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$details = get_blog_details( $blog_id, false );
$key = md5( $details->domain . $details->path );
@ -190,7 +190,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
function test_data_in_tables_after_wpmu_delete_blog_drop_true() {
global $wpdb;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
// Delete the site and force a table drop.
wpmu_delete_blog( $blog_id, true );
@ -247,7 +247,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* The site count of a network should change when a site is flagged as 'deleted'.
*/
function test_network_count_after_wpmu_delete_blog_drop_false() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
// Delete the site without forcing a table drop.
wpmu_delete_blog( $blog_id, false );
@ -261,7 +261,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* The site count of a network should change when a site is fully deleted.
*/
function test_blog_count_after_wpmu_delete_blog_drop_true() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
// Delete the site and force a table drop.
wpmu_delete_blog( $blog_id, true );
@ -283,7 +283,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
// Upload a file to the main site on the network.
$file1 = wp_upload_bits( $filename, null, $contents );
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
$file2 = wp_upload_bits( $filename, null, $contents );
@ -329,7 +329,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
*/
function test_get_blog_details_when_site_does_not_exist() {
// Create an unused site so that we can then assume an invalid site ID.
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$blog_id++;
// Prime the cache for an invalid site.
@ -339,7 +339,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
$this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) );
// Create a site in the invalid site's place.
$this->factory->blog->create();
self::$factory->blog->create();
// When a new site is created, its cache is cleared through refresh_blog_details.
$this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
@ -370,7 +370,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
update_blog_details( $blog_id, array( 'spam' => 1 ) );
add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 );
@ -394,7 +394,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 );
update_blog_status( $blog_id, 'spam', 1 );
@ -417,7 +417,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 );
update_blog_status( $blog_id, 'archived', 1 );
@ -440,7 +440,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
update_blog_details( $blog_id, array( 'archived' => 1 ) );
add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 );
@ -463,7 +463,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 );
update_blog_status( $blog_id, 'deleted', 1 );
@ -486,7 +486,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
update_blog_details( $blog_id, array( 'deleted' => 1 ) );
add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 );
@ -510,7 +510,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 );
update_blog_status( $blog_id, 'mature', 1 );
@ -533,7 +533,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
update_blog_details( $blog_id, array( 'mature' => 1 ) );
add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 );
@ -557,7 +557,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 );
update_blog_status( $blog_id, 'public', 0 );
@ -583,7 +583,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* @ticket 14511
*/
function test_wp_get_sites_with_default_arguments() {
$this->factory->blog->create( array( 'site_id' => 2 ) );
self::$factory->blog->create( array( 'site_id' => 2 ) );
$this->assertCount( 1, wp_get_sites() );
}
@ -599,7 +599,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* A network ID of null should query for all public sites on all networks.
*/
function test_wp_get_sites_with_network_id_null() {
$this->factory->blog->create( array( 'site_id' => 2 ) );
self::$factory->blog->create( array( 'site_id' => 2 ) );
$this->assertCount( 2, wp_get_sites( array( 'network_id' => null ) ) );
}
@ -608,7 +608,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Expect only sites on the specified network ID to be returned.
*/
function test_wp_get_sites_with_specific_network_id() {
$this->factory->blog->create( array( 'site_id' => 2 ) );
self::$factory->blog->create( array( 'site_id' => 2 ) );
$this->assertCount( 1, wp_get_sites( array( 'network_id' => 2 ) ) );
}
@ -617,7 +617,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Expect sites from both networks if both network IDs are specified.
*/
function test_wp_get_sites_with_multiple_network_ids() {
$this->factory->blog->create( array( 'site_id' => 2 ) );
self::$factory->blog->create( array( 'site_id' => 2 ) );
$this->assertCount( 2, wp_get_sites( array( 'network_id' => array( 1, 2 ) ) ) );
}
@ -626,7 +626,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Queries for public or non public sites should work across all networks if network ID is null.
*/
function test_wp_get_sites_with_public_meta_on_all_networks() {
$this->factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) );
self::$factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) );
$this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => null ) ) );
$this->assertcount( 1, wp_get_sites( array( 'public' => 0, 'network_id' => null ) ) );
@ -636,7 +636,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* If a network ID is specified, queries for public sites should be restricted to that network.
*/
function test_wp_get_sites_with_public_meta_restrict_to_one_network() {
$this->factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) );
self::$factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) );
$this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => 1 ) ) );
$this->assertCount( 0, wp_get_sites( array( 'public' => 1, 'network_id' => 2 ) ) );
@ -647,7 +647,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
*/
function test_wp_get_sites_limit_offset() {
// Create 2 more sites (in addition to the default one)
$this->factory->blog->create_many( 2 );
self::$factory->blog->create_many( 2 );
// Expect first 2 sites when using limit
$this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) );
@ -670,8 +670,8 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* @ticket 27952
*/
function test_posts_count() {
$this->factory->post->create();
$post2 = $this->factory->post->create();
self::$factory->post->create();
$post2 = self::$factory->post->create();
$this->assertEquals( 2, get_blog_details()->post_count );
wp_delete_post( $post2 );
@ -701,7 +701,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
);
foreach ( $network_ids as &$id ) {
$id = $this->factory->network->create( $id );
$id = self::$factory->network->create( $id );
}
unset( $id );
@ -714,7 +714,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
);
foreach ( $ids as &$id ) {
$id = $this->factory->blog->create( $id );
$id = self::$factory->blog->create( $id );
}
unset( $id );
@ -772,7 +772,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* the blog ID is requested through get_blog_id_from_url().
*/
function test_get_blog_id_from_url() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$details = get_blog_details( $blog_id, false );
$key = md5( $details->domain . $details->path );
@ -785,7 +785,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Test the case insensitivity of the site lookup.
*/
function test_get_blog_id_from_url_is_case_insensitive() {
$blog_id = $this->factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) );
$blog_id = self::$factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) );
$details = get_blog_details( $blog_id, false );
$this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
@ -795,7 +795,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Test the first and cached responses for a site that does not exist.
*/
function test_get_blog_id_from_url_that_does_not_exist() {
$blog_id = $this->factory->blog->create( array( 'path' => '/xyz' ) );
$blog_id = self::$factory->blog->create( array( 'path' => '/xyz' ) );
$details = get_blog_details( $blog_id, false );
$this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
@ -807,7 +807,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`.
*/
function test_get_blog_id_from_url_with_deleted_flag() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$details = get_blog_details( $blog_id, false );
$key = md5( $details->domain . $details->path );
wpmu_delete_blog( $blog_id );
@ -821,7 +821,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* -1 after an attempt at `get_blog_id_from_url()` is made.
*/
function test_get_blog_id_from_url_after_dropped() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$details = get_blog_details( $blog_id, false );
$key = md5( $details->domain . $details->path );
wpmu_delete_blog( $blog_id, true );
@ -850,7 +850,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Test with a site ID other than the main site to ensure a false response.
*/
function test_is_main_site_is_false_with_other_blog_id() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$this->assertFalse( is_main_site( $blog_id ) );
}
@ -859,7 +859,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* Test with no passed ID after switching to another site ID.
*/
function test_is_main_site_is_false_after_switch_to_blog() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
$this->assertFalse( is_main_site() );
@ -878,7 +878,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
$this->assertEquals( '', $info['error'] );
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
switch_to_blog( $blog_id );
$info = wp_upload_dir();
@ -900,8 +900,8 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* another site on the network.
*/
function test_get_blog_post_from_another_site_on_network() {
$blog_id = $this->factory->blog->create();
$post_id = $this->factory->post->create(); // Create a post on the primary site, ID 1.
$blog_id = self::$factory->blog->create();
$post_id = self::$factory->post->create(); // Create a post on the primary site, ID 1.
$post = get_post( $post_id );
switch_to_blog( $blog_id );
@ -915,7 +915,7 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
* If get_blog_post() is used on the same site, it should still work.
*/
function test_get_blog_post_from_same_site() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) );
}

View File

@ -25,7 +25,7 @@ class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase {
}
function test_update_blog_details() {
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
$result = update_blog_details( $blog_id, array( 'domain' => 'example.com', 'path' => 'my_path/' ) );
@ -53,7 +53,7 @@ class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase {
global $test_action_counter;
$test_action_counter = 0;
$blog_id = $this->factory->blog->create();
$blog_id = self::$factory->blog->create();
// Set an initial value of '1' for the flag when '0' is the flag value being tested.
if ( '0' === $flag_value ) {

View File

@ -63,13 +63,13 @@ class Tests_Multisite_WpmuValidateUserSignup extends WP_UnitTestCase {
}
public function test_should_fail_for_existing_user_name() {
$u = $this->factory->user->create( array( 'user_login' => 'foo123' ) );
$u = self::$factory->user->create( array( 'user_login' => 'foo123' ) );
$v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
$this->assertContains( 'user_name', $v['errors']->get_error_codes() );
}
public function test_should_fail_for_existing_user_email() {
$u = $this->factory->user->create( array( 'user_email' => 'foo@example.com' ) );
$u = self::$factory->user->create( array( 'user_email' => 'foo@example.com' ) );
$v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
$this->assertContains( 'user_email', $v['errors']->get_error_codes() );
}

View File

@ -17,10 +17,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
function test_request_json() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'display_name' => 'John Doe',
) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_author' => $user->ID,
'post_title' => 'Hello World',
) );
@ -60,10 +60,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
function test_request_jsonp() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'display_name' => 'John Doe',
) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_author' => $user->ID,
'post_title' => 'Hello World',
) );
@ -83,10 +83,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
function test_request_jsonp_invalid_callback() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'display_name' => 'John Doe',
) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_author' => $user->ID,
'post_title' => 'Hello World',
) );
@ -118,10 +118,10 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
function test_request_xml() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'display_name' => 'John Doe',
) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_author' => $user->ID,
'post_title' => 'Hello World',
) );
@ -177,11 +177,11 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
$this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
}
$child = $this->factory->blog->create();
$child = self::$factory->blog->create();
switch_to_blog( $child );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Hello Child Blog',
) );
@ -207,7 +207,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
$this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) );
$this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$url = get_permalink( $post_id );
$url_encoded = urlencode( $url );

View File

@ -12,7 +12,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
}
function test_add_oembed_discovery_links_to_post() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->go_to( get_permalink( $post_id ) );
$this->assertQueryTrue( 'is_single', 'is_singular' );
@ -28,7 +28,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
}
function test_add_oembed_discovery_links_to_page() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_type' => 'page'
));
$this->go_to( get_permalink( $post_id ) );
@ -46,9 +46,9 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
}
function test_add_oembed_discovery_links_to_attachment() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = $this->factory->attachment->create_object( $file, $post_id, array(
$attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
) );

View File

@ -9,7 +9,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data() {
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Some Post',
) );
@ -33,11 +33,11 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
* Test get_oembed_response_data with an author.
*/
function test_get_oembed_response_data_author() {
$user_id = $this->factory->user->create( array(
$user_id = self::$factory->user->create( array(
'display_name' => 'John Doe',
) );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Some Post',
'post_author' => $user_id,
) );
@ -61,7 +61,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
function test_get_oembed_response_link() {
remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich' );
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Some Post',
) );
@ -81,7 +81,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_with_draft_post() {
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'draft',
) );
@ -89,7 +89,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_with_scheduled_post() {
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'future',
'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ),
) );
@ -98,7 +98,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_with_private_post() {
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_status' => 'private',
) );
@ -106,7 +106,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_maxwidth_too_high() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = get_oembed_response_data( $post, 1000 );
@ -115,7 +115,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_maxwidth_too_low() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = get_oembed_response_data( $post, 100 );
@ -124,7 +124,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_maxwidth_invalid() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$data = get_oembed_response_data( $post, '400;" DROP TABLES' );
@ -138,9 +138,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_with_thumbnail() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array(
$attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array(
'post_mime_type' => 'image/jpeg',
) );
set_post_thumbnail( $post, $attachment_id );
@ -154,9 +154,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
}
function test_get_oembed_response_data_for_attachment() {
$parent = $this->factory->post->create();
$parent = self::$factory->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$post = $this->factory->attachment->create_object( $file, $parent, array(
$post = self::$factory->attachment->create_object( $file, $parent, array(
'post_mime_type' => 'image/jpeg',
) );

View File

@ -12,7 +12,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
$this->markTestSkipped( 'xdebug is required for this test' );
}
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Hello World',
) );
@ -46,7 +46,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
$this->markTestSkipped( 'xdebug is required for this test' );
}
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Hello World',
) );

View File

@ -12,7 +12,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase {
function test_get_post_embed_url_with_pretty_permalinks() {
update_option( 'permalink_structure', '/%postname%' );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$permalink = get_permalink( $post_id );
$embed_url = get_post_embed_url( $post_id );
@ -22,7 +22,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase {
}
function test_get_post_embed_url_with_ugly_permalinks() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$permalink = get_permalink( $post_id );
$embed_url = get_post_embed_url( $post_id );

View File

@ -5,11 +5,11 @@
*/
class Tests_Embed_Template extends WP_UnitTestCase {
function test_oembed_output_post() {
$user = $this->factory->user->create_and_get( array(
$user = self::$factory->user->create_and_get( array(
'display_name' => 'John Doe',
) );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_author' => $user->ID,
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
@ -30,13 +30,13 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_post_with_thumbnail() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
'post_excerpt' => 'Bar Baz',
) );
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = $this->factory->attachment->create_object( $file, $post_id, array(
$attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
) );
set_post_thumbnail( $post_id, $attachment_id );
@ -72,9 +72,9 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_attachment() {
$post = $this->factory->post->create_and_get();
$post = self::$factory->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array(
$attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array(
'post_mime_type' => 'image/jpeg',
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
@ -97,7 +97,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_draft_post() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
'post_excerpt' => 'Bar Baz',
@ -118,7 +118,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_scheduled_post() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
'post_excerpt' => 'Bar Baz',
@ -140,7 +140,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_private_post() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
'post_excerpt' => 'Bar Baz',
@ -161,10 +161,10 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_oembed_output_private_post_with_permissions() {
$user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $user_id );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
'post_excerpt' => 'Bar Baz',
@ -193,7 +193,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_wp_oembed_excerpt_more() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_content' => 'Foo Bar',
) );
@ -214,15 +214,15 @@ class Tests_Embed_Template extends WP_UnitTestCase {
function test_is_embed_post() {
$this->assertFalse( is_embed() );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->go_to( get_post_embed_url( $post_id ) );
$this->assertTrue( is_embed() );
}
function test_is_embed_attachment() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = $this->factory->attachment->create_object( $file, $post_id, array(
$attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
) );
$this->go_to( get_post_embed_url( $attachment_id ) );
@ -240,7 +240,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_get_post_embed_html() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';

View File

@ -98,10 +98,10 @@ class Tests_Multisite_Option extends WP_UnitTestCase {
}
function test_with_another_site() {
$user_id = $this->factory->user->create();
$user_id = self::$factory->user->create();
$this->assertInternalType( 'integer', $user_id );
$blog_id = $this->factory->blog->create( array(
$blog_id = self::$factory->blog->create( array(
'user_id' => $user_id,
'meta' => array(
'public' => 1,

View File

@ -11,7 +11,7 @@ if ( is_multisite() ) :
*/
class Tests_Option_NetworkOption extends WP_UnitTestCase {
function test_add_network_option_not_available_on_other_network() {
$id = $this->factory->network->create();
$id = self::$factory->network->create();
$option = rand_str();
$value = rand_str();
@ -20,7 +20,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase {
}
function test_add_network_option_available_on_same_network() {
$id = $this->factory->network->create();
$id = self::$factory->network->create();
$option = rand_str();
$value = rand_str();
@ -29,7 +29,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase {
}
function test_delete_network_option_on_only_one_network() {
$id = $this->factory->network->create();
$id = self::$factory->network->create();
$option = rand_str();
$value = rand_str();

View File

@ -5,7 +5,7 @@ class Tests_User_Settings extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->user_id = $this->factory->user->create( array(
$this->user_id = self::$factory->user->create( array(
'role' => 'administrator'
) );

View File

@ -545,9 +545,9 @@ class Tests_Post extends WP_UnitTestCase {
function test_get_page_by_path_priority() {
global $wpdb;
$attachment = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );
$page = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );
$other_att = $this->factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );
$attachment = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );
$page = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );
$other_att = self::$factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );
$wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) );
clean_post_cache( $page->ID );
@ -565,7 +565,7 @@ class Tests_Post extends WP_UnitTestCase {
}
function test_wp_publish_post() {
$draft_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );
$draft_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
$post = get_post( $draft_id );
$this->assertEquals( 'draft', $post->post_status );
@ -581,7 +581,7 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_wp_insert_post_and_wp_publish_post_with_future_date() {
$future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_status' => 'publish',
'post_date' => $future_date,
) );
@ -641,7 +641,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 22883
*/
function test_get_page_uri_with_stdclass_post_object() {
$post_id = $this->factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
$post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
// Mimick an old stdClass post object, missing the ancestors field.
$post_array = (object) get_post( $post_id, ARRAY_A );
@ -664,8 +664,8 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 15963
*/
function test_get_post_uri_check_orphan() {
$parent_id = $this->factory->post->create( array( 'post_name' => 'parent' ) );
$child_id = $this->factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
$parent_id = self::$factory->post->create( array( 'post_name' => 'parent' ) );
$child_id = self::$factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
// check the parent for good measure
$this->assertEquals( 'parent', get_page_uri( $parent_id ) );
@ -683,8 +683,8 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_get_post_ancestors_within_loop() {
global $post;
$parent_id = $this->factory->post->create();
$post = $this->factory->post->create_and_get( array( 'post_parent' => $parent_id ) );
$parent_id = self::$factory->post->create();
$post = self::$factory->post->create_and_get( array( 'post_parent' => $parent_id ) );
$this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) );
}
@ -692,7 +692,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 23474
*/
function test_update_invalid_post_id() {
$post_id = $this->factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
$post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
$post = get_post( $post_id, ARRAY_A );
$post['ID'] = 123456789;
@ -707,7 +707,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_parse_post_content_single_page() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) );
$post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
@ -718,7 +718,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_parse_post_content_multi_page() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
@ -729,7 +729,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_parse_post_content_remaining_single_page() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) );
$post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
@ -740,7 +740,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_parse_post_content_remaining_multi_page() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
@ -754,7 +754,7 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_parse_post_content_starting_with_nextpage() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 1, $multipage );
@ -768,7 +768,7 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_parse_post_content_starting_with_nextpage_multi() {
global $multipage, $pages, $numpages;
$post_id = $this->factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
$post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
$post = get_post( $post_id );
setup_postdata( $post );
$this->assertEquals( 0, $multipage );
@ -809,7 +809,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_wp_count_posts() {
$post_type = rand_str(20);
register_post_type( $post_type );
$this->factory->post->create( array(
self::$factory->post->create( array(
'post_type' => $post_type,
'post_author' => self::$editor_id
) );
@ -822,7 +822,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_wp_count_posts_filtered() {
$post_type = rand_str(20);
register_post_type( $post_type );
$this->factory->post->create_many( 3, array(
self::$factory->post->create_many( 3, array(
'post_type' => $post_type,
'post_author' => self::$editor_id
) );
@ -842,7 +842,7 @@ class Tests_Post extends WP_UnitTestCase {
}
function test_wp_count_posts_insert_invalidation() {
$post_ids = $this->factory->post->create_many( 3 );
$post_ids = self::$factory->post->create_many( 3 );
$initial_counts = wp_count_posts();
$key = array_rand( $post_ids );
@ -860,7 +860,7 @@ class Tests_Post extends WP_UnitTestCase {
}
function test_wp_count_posts_trash_invalidation() {
$post_ids = $this->factory->post->create_many( 3 );
$post_ids = self::$factory->post->create_many( 3 );
$initial_counts = wp_count_posts();
$key = array_rand( $post_ids );
@ -881,7 +881,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 13771
*/
function test_get_the_date_with_id_returns_correct_time() {
$post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
}
@ -899,7 +899,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 28310
*/
function test_get_the_time_with_id_returns_correct_time() {
$post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
}
@ -917,7 +917,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 28310
*/
function test_get_post_time_with_id_returns_correct_time() {
$post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
}
@ -935,7 +935,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 28310
*/
function test_get_post_modified_time_with_id_returns_correct_time() {
$post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
$this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
}
@ -973,7 +973,7 @@ class Tests_Post extends WP_UnitTestCase {
register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
register_taxonomy( $tax, $post_type );
$post = $this->factory->post->create( array( 'post_type' => $post_type ) );
$post = self::$factory->post->create( array( 'post_type' => $post_type ) );
wp_set_object_terms( $post, rand_str(), $tax );
$wp_tag_cloud = wp_tag_cloud( array(
@ -1015,7 +1015,7 @@ class Tests_Post extends WP_UnitTestCase {
require_once( ABSPATH . '/wp-admin/includes/post.php' );
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$data = array(
'post_ID' => $post_id,
@ -1043,7 +1043,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 31168
*/
function test_wp_insert_post_default_comment_ping_status_open() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_author' => self::$editor_id,
'post_status' => 'public',
'post_content' => rand_str(),
@ -1059,7 +1059,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 31168
*/
function test_wp_insert_post_page_default_comment_ping_status_closed() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_author' => self::$editor_id,
'post_status' => 'public',
'post_content' => rand_str(),
@ -1078,7 +1078,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_wp_insert_post_cpt_default_comment_ping_status_open() {
$post_type = rand_str(20);
register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_author' => self::$editor_id,
'post_status' => 'public',
'post_content' => rand_str(),
@ -1098,7 +1098,7 @@ class Tests_Post extends WP_UnitTestCase {
function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
$post_type = rand_str(20);
register_post_type( $post_type );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_author' => self::$editor_id,
'post_status' => 'public',
'post_content' => rand_str(),
@ -1127,7 +1127,7 @@ class Tests_Post extends WP_UnitTestCase {
$this->assertTrue( current_user_can( 'edit_published_posts' ) );
// Create a sticky post.
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Will be changed',
'post_content' => 'Will be changed',
) );
@ -1156,7 +1156,7 @@ class Tests_Post extends WP_UnitTestCase {
*/
function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
// Create a sticky post.
$post = $this->factory->post->create_and_get( array(
$post = self::$factory->post->create_and_get( array(
'post_title' => 'Will be changed',
'post_content' => 'Will be changed',
) );
@ -1191,7 +1191,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 32585
*/
public function test_wp_insert_post_author_zero() {
$post_id = $this->factory->post->create( array( 'post_author' => 0 ) );
$post_id = self::$factory->post->create( array( 'post_author' => 0 ) );
$this->assertEquals( 0, get_post( $post_id )->post_author );
}
@ -1200,7 +1200,7 @@ class Tests_Post extends WP_UnitTestCase {
* @ticket 32585
*/
public function test_wp_insert_post_author_null() {
$post_id = $this->factory->post->create( array( 'post_author' => null ) );
$post_id = self::$factory->post->create( array( 'post_author' => null ) );
$this->assertEquals( self::$editor_id, get_post( $post_id )->post_author );
}

View File

@ -31,7 +31,7 @@ EOF;
no such tag
EOF;
$id = $this->factory->post->create( array( 'post_content' => $content ) );
$id = self::$factory->post->create( array( 'post_content' => $content ) );
$post = get_post($id);
$this->assertEquals( $expected, $post->post_content );
@ -48,7 +48,7 @@ EOF;
<i>italics</i>
EOF;
$id = $this->factory->post->create( array( 'post_content' => $content ) );
$id = self::$factory->post->create( array( 'post_content' => $content ) );
$post = get_post($id);
$this->assertEquals( $expected, $post->post_content );
@ -65,7 +65,7 @@ EOF;
<img src='foo' width='500' />
EOF;
$id = $this->factory->post->create( array( 'post_content' => $content ) );
$id = self::$factory->post->create( array( 'post_content' => $content ) );
$post = get_post($id);
$this->assertEquals( $expected, $post->post_content );
@ -84,7 +84,7 @@ EOF;
<img src='foo' width='500' height='300' />
EOF;
$id = $this->factory->post->create( array( 'post_content' => $content ) );
$id = self::$factory->post->create( array( 'post_content' => $content ) );
$post = get_post($id);
$this->assertEquals( $expected, $post->post_content );
@ -104,7 +104,7 @@ that's continued after the jump</em>
breaks the graf</p>
EOF;
$id = $this->factory->post->create( array( 'post_content' => $content ) );
$id = self::$factory->post->create( array( 'post_content' => $content ) );
$post = get_post($id);
$this->assertEquals( $content, $post->post_content );

View File

@ -9,7 +9,7 @@ class Tests_Post_Formats extends WP_UnitTestCase {
}
function test_set_get_post_format_for_post() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$format = get_post_format( $post_id );
$this->assertFalse( $format );
@ -37,7 +37,7 @@ class Tests_Post_Formats extends WP_UnitTestCase {
* @ticket 22473
*/
function test_set_get_post_format_for_page() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$format = get_post_format( $post_id );
$this->assertFalse( $format );
@ -69,7 +69,7 @@ class Tests_Post_Formats extends WP_UnitTestCase {
}
function test_has_format() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->assertFalse( has_post_format( 'standard', $post_id ) );
$this->assertFalse( has_post_format( '', $post_id ) );
@ -111,11 +111,11 @@ $href
$commentary
DATA;
$link_post_id = $this->factory->post->create( array( 'post_content' => $link ) );
$link_post_id = self::$factory->post->create( array( 'post_content' => $link ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) );
$this->assertEquals( false, $content_link );
$link_with_post_id = $this->factory->post->create( array( 'post_content' => $link_with_commentary ) );
$link_with_post_id = self::$factory->post->create( array( 'post_content' => $link_with_commentary ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
$this->assertEquals( false, $content_link );
@ -125,20 +125,20 @@ DATA;
$content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
$this->assertEquals( false, $content_link );
$empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) );
$empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
$this->assertEquals( false, $content_link );
$comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) );
$comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
$this->assertEquals( false, $content_link );
// Now with an href
$href_post_id = $this->factory->post->create( array( 'post_content' => $href ) );
$href_post_id = self::$factory->post->create( array( 'post_content' => $href ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) );
$this->assertEquals( $link, $content_link );
$href_with_post_id = $this->factory->post->create( array( 'post_content' => $href_with_commentary ) );
$href_with_post_id = self::$factory->post->create( array( 'post_content' => $href_with_commentary ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
$this->assertEquals( $link, $content_link );
@ -148,11 +148,11 @@ DATA;
$content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
$this->assertEquals( $link, $content_link );
$empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) );
$empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
$this->assertEquals( false, $content_link );
$comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) );
$comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
$content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
$this->assertEquals( false, $content_link );
}

View File

@ -9,16 +9,16 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
$this->post_id = $this->factory->post->create();
$this->post_id = self::$factory->post->create();
}
/**
* @ticket 30883
*/
public function test_with_utf8_category_slugs() {
$cat_id1 = $this->factory->category->create( array( 'name' => 'Первая рубрика' ) );
$cat_id2 = $this->factory->category->create( array( 'name' => 'Вторая рубрика' ) );
$cat_id3 = $this->factory->category->create( array( 'name' => '25кадр' ) );
$cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) );
$cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) );
$cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' );
$this->go_to( home_url( "?cat=$cat_id1" ) );
@ -35,9 +35,9 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
* @ticket 30883
*/
public function test_with_utf8_tag_slugs() {
$tag_id1 = $this->factory->tag->create( array( 'name' => 'Первая метка' ) );
$tag_id2 = $this->factory->tag->create( array( 'name' => 'Вторая метка' ) );
$tag_id3 = $this->factory->tag->create( array( 'name' => '25кадр' ) );
$tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) );
$tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) );
$tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' );
$tag1 = get_term( $tag_id1, 'post_tag' );
@ -59,9 +59,9 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
*/
public function test_with_utf8_term_slugs() {
register_taxonomy( 'wptests_tax', 'post' );
$term_id1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
$term_id2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
$term_id3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
$term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
$term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
$term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' );
$term1 = get_term( $term_id1, 'wptests_tax' );

View File

@ -15,7 +15,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
function test_get_pages_cache() {
global $wpdb;
$this->factory->post->create_many( 3, array( 'post_type' => 'page' ) );
self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
wp_cache_delete( 'last_changed', 'posts' );
$this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
@ -99,7 +99,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 20376
*/
function test_get_pages_meta() {
$posts = $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) );
$posts = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
add_post_meta( $posts[0], 'some-meta-key', '0' );
add_post_meta( $posts[1], 'some-meta-key', '' );
add_post_meta( $posts[2], 'some-meta-key', '1' );
@ -116,7 +116,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
$page_ids = array();
foreach ( range( 1, 20 ) as $i )
$page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_ids[] = self::$factory->post->create( array( 'post_type' => 'page' ) );
$inc = array_slice( $page_ids, 0, 10 );
sort( $inc );
@ -138,10 +138,10 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 9470
*/
function test_get_pages_parent() {
$page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
$page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );
$page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
$page_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
$page_id3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );
$page_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
$pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) );
$this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );
@ -166,7 +166,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 22389
*/
function test_wp_dropdown_pages() {
$this->factory->post->create_many( 5, array( 'post_type' => 'page' ) );
self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) );
preg_match_all( '#<option#', wp_dropdown_pages( 'echo=0' ), $matches );
@ -177,8 +177,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 22208
*/
function test_get_chidren_fields_ids() {
$post_id = $this->factory->post->create();
$child_ids = $this->factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
$post_id = self::$factory->post->create();
$child_ids = self::$factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
$post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) );
$this->assertEqualSets( $child_ids, $post_ids );
@ -189,10 +189,10 @@ class Tests_Post_getPages extends WP_UnitTestCase {
*/
function test_get_pages_hierarchical_and_no_parent() {
global $wpdb;
$page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) );
$page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) );
$pages = get_pages(); // Defaults: hierarchical = true, parent = -1
$pages_default_args = get_pages( array( 'hierarchical' => true, 'parent' => -1 ) );
@ -218,10 +218,10 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 18701
*/
public function test_get_pages_hierarchical_empty_child_of() {
$page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$pages = get_pages(); // Defaults: hierarchical = true, child_of = '', parent = -1
$default_args = get_pages( array(
@ -252,10 +252,10 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 18701
*/
public function test_get_pages_non_hierarchical_empty_child_of() {
$page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$pages = get_pages( array( 'hierarchical' => false ) ); // child_of = '', parent = -1
@ -278,11 +278,11 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 18701
*/
public function test_get_pages_hierarchical_non_empty_child_of() {
$page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
$page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
$page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$pages = get_pages( array( 'child_of' => $page_1 ) ); // Defaults: hierarchical = true, parent = -1.
@ -306,11 +306,11 @@ class Tests_Post_getPages extends WP_UnitTestCase {
* @ticket 18701
*/
public function test_get_pages_non_hierarchical_non_empty_child_of() {
$page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
$page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
$page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
$pages = get_pages( array( 'hierarchical' => false, 'child_of' => $page_1 ) );
@ -338,7 +338,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
$type = 'taco';
register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) );
$posts = $this->factory->post->create_many( 2, array( 'post_type' => $type ) );
$posts = self::$factory->post->create_many( 2, array( 'post_type' => $type ) );
$post_id = reset( $posts );
$this->go_to( "/?p=$post_id&post_type=$type" );
@ -360,10 +360,10 @@ class Tests_Post_getPages extends WP_UnitTestCase {
}
function test_exclude_tree() {
$post_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) );
$post_id3 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) );
$post_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) );
$post_id3 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$post_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) );
$all = get_pages();
@ -384,8 +384,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
$exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
$this->assertCount( 0, $exclude5 );
$post_id5 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id6 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) );
$post_id5 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$post_id6 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) );
$exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
$this->assertCount( 2, $exclude6 );

View File

@ -9,7 +9,7 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
$this->post_id = $this->factory->post->create();
$this->post_id = self::$factory->post->create();
}
public function test_with_tags() {
@ -22,7 +22,7 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase {
}
public function test_with_categories() {
$cats = $this->factory->category->create_many( 2 );
$cats = self::$factory->category->create_many( 2 );
wp_set_post_terms( $this->post_id, $cats, 'category' );
$cat0 = get_term( $cats[0], 'category' );
@ -57,9 +57,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase {
* @ticket 30883
*/
public function test_with_utf8_category_slugs() {
$cat_id1 = $this->factory->category->create( array( 'name' => 'Первая рубрика' ) );
$cat_id2 = $this->factory->category->create( array( 'name' => 'Вторая рубрика' ) );
$cat_id3 = $this->factory->category->create( array( 'name' => '25кадр' ) );
$cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) );
$cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) );
$cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' );
$found = get_post_class( '', $this->post_id );
@ -73,9 +73,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase {
* @ticket 30883
*/
public function test_with_utf8_tag_slugs() {
$tag_id1 = $this->factory->tag->create( array( 'name' => 'Первая метка' ) );
$tag_id2 = $this->factory->tag->create( array( 'name' => 'Вторая метка' ) );
$tag_id3 = $this->factory->tag->create( array( 'name' => '25кадр' ) );
$tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) );
$tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) );
$tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' );
$found = get_post_class( '', $this->post_id );
@ -90,9 +90,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase {
*/
public function test_with_utf8_term_slugs() {
register_taxonomy( 'wptests_tax', 'post' );
$term_id1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
$term_id2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
$term_id3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
$term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
$term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
$term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' );
$found = get_post_class( '', $this->post_id );

View File

@ -59,7 +59,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user(){
$current_user = get_current_user_id();
$u = $this->factory->user->create();
$u = self::$factory->user->create();
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, true );
@ -70,7 +70,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_should_default_to_false(){
$current_user = get_current_user_id();
$u = $this->factory->user->create();
$u = self::$factory->user->create();
wp_set_current_user( $u );
$this->assertSame( get_posts_by_author_sql( 'post', true, $u, false ), get_posts_by_author_sql( 'post', true, $u ) );
@ -80,7 +80,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author(){
$current_user = get_current_user_id();
$u = $this->factory->user->create();
$u = self::$factory->user->create();
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
@ -91,8 +91,8 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author(){
$current_user = get_current_user_id();
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$u1 = self::$factory->user->create();
$u2 = self::$factory->user->create();
wp_set_current_user( $u1 );
$maybe_string = get_posts_by_author_sql( 'post', true, $u2, false );
@ -103,7 +103,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided(){
$current_user = get_current_user_id();
$u = $this->factory->user->create();
$u = self::$factory->user->create();
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
@ -115,7 +115,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){
$current_user = get_current_user_id();
$u = $this->factory->user->create( array( 'role' => 'administrator' ) );
$u = self::$factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, null, false );
@ -130,7 +130,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) );
register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) );
$current_user = get_current_user_id();
$u = $this->factory->user->create( array( 'role' => 'editor' ) );
$u = self::$factory->user->create( array( 'role' => 'editor' ) );
$editor_role = get_role('editor');
$editor_role->add_cap( 'read_private_baz' );
wp_set_current_user( $u );

View File

@ -27,15 +27,15 @@ class Tests_List_Pages extends WP_UnitTestCase {
global $wpdb;
$wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' );
$pages = array();
$this->factory->user->create();
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );
self::$factory->user->create();
$pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );
$pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );
$pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );
foreach ( $pages as $page ) {
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );
$this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );
$this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );
$this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );
}
}

View File

@ -8,7 +8,7 @@ class Tests_Post_Meta extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author = new WP_User( $this->factory->user->create( array( 'role' => 'editor' ) ) );
$this->author = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) );
$post = array(
'post_author' => $this->author->ID,

View File

@ -16,11 +16,11 @@ class Test_Nav_Menus extends WP_UnitTestCase {
}
function test_wp_get_associated_nav_menu_items() {
$tag_id = $this->factory->tag->create();
$cat_id = $this->factory->category->create();
$post_id = $this->factory->post->create();
$post_2_id = $this->factory->post->create();
$page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$tag_id = self::$factory->tag->create();
$cat_id = self::$factory->category->create();
$post_id = self::$factory->post->create();
$post_2_id = self::$factory->post->create();
$page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array(
'menu-item-type' => 'taxonomy',
@ -107,7 +107,7 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$this->assertEquals( 'Wordpress.org', $custom_item->title );
// Update the orphan with an associated nav menu
wp_update_nav_menu_item( $this->menu_id, $custom_item_id, array(
wp_update_nav_menu_item( $this->menu_id, $custom_item_id, array(
'menu-item-title' => 'WordPress.org',
) );
$menu_items = wp_get_nav_menu_items( $this->menu_id );
@ -119,8 +119,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
public function test_wp_get_nav_menu_items_with_taxonomy_term() {
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
$t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
$child_terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) );
$t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
$child_terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) );
$term_menu_item = wp_update_nav_menu_item( $this->menu_id, 0, array(
'menu-item-type' => 'taxonomy',
@ -140,7 +140,7 @@ class Test_Nav_Menus extends WP_UnitTestCase {
* @ticket 29460
*/
function test_orderby_name_by_default() {
// We are going to create a random number of menus (min 2, max 10)
// We are going to create a random number of menus (min 2, max 10)
$menus_no = rand( 2, 10 );
for ( $i = 0; $i <= $menus_no; $i++ ) {
@ -148,14 +148,14 @@ class Test_Nav_Menus extends WP_UnitTestCase {
}
// This is the expected array of menu names
$expected_nav_menus_names = wp_list_pluck(
$expected_nav_menus_names = wp_list_pluck(
get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'name' ) ),
'name'
);
// And this is what we got when calling wp_get_nav_menus()
$nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' );
$this->assertEquals( $nav_menus_names, $expected_nav_menus_names );
}
}

View File

@ -6,7 +6,7 @@
class Tests_Post_Objects extends WP_UnitTestCase {
function test_get_post() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
$post = get_post( $id );
$this->assertInstanceOf( 'WP_Post', $post );
@ -67,9 +67,9 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_post_ancestors() {
$parent_id = $this->factory->post->create();
$child_id = $this->factory->post->create();
$grandchild_id = $this->factory->post->create();
$parent_id = self::$factory->post->create();
$child_id = self::$factory->post->create();
$grandchild_id = self::$factory->post->create();
$updated = wp_update_post( array( 'ID' => $child_id, 'post_parent' => $parent_id ) );
$this->assertEquals( $updated, $child_id );
$updated = wp_update_post( array( 'ID' => $grandchild_id, 'post_parent' => $child_id ) );
@ -99,7 +99,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_post_category_property() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$post = get_post( $post_id );
$this->assertInternalType( 'array', $post->post_category );
@ -118,7 +118,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_tags_input_property() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$post = get_post( $post_id );
$this->assertInternalType( 'array', $post->tags_input );
@ -135,7 +135,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_page_template_property() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$post = get_post( $post_id );
$this->assertInternalType( 'string', $post->page_template );
@ -155,7 +155,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_post_filter() {
$post = get_post( $this->factory->post->create( array(
$post = get_post( self::$factory->post->create( array(
'post_title' => "Mary's home"
) ) );
@ -178,7 +178,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_post_identity() {
$post = get_post( $this->factory->post->create() );
$post = get_post( self::$factory->post->create() );
$post->foo = 'bar';
@ -187,7 +187,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
}
function test_get_post_array() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
$post = get_post( $id, ARRAY_A );
@ -202,7 +202,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
function test_get_post_cache() {
global $wpdb;
$id = $this->factory->post->create();
$id = self::$factory->post->create();
wp_cache_delete( $id, 'posts' );
// get_post( stdClass ) should not prime the cache

View File

@ -41,7 +41,7 @@ class Tests_Post_Output extends WP_UnitTestCase {
This is the <b>body</b>.
EOF;
$post_id = $this->factory->post->create( compact( 'post_content' ) );
$post_id = self::$factory->post->create( compact( 'post_content' ) );
$expected = <<<EOF
<p><i>This is the excerpt.</i><br />
@ -76,7 +76,7 @@ baz = bar
EOF;
$post_id = $this->factory->post->create( compact( 'post_content' ) );
$post_id = self::$factory->post->create( compact( 'post_content' ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertTrue( is_single() );
$this->assertTrue( have_posts() );
@ -114,7 +114,7 @@ EOF;
EOF;
$post_id = $this->factory->post->create( compact( 'post_content' ) );
$post_id = self::$factory->post->create( compact( 'post_content' ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertTrue( is_single() );
$this->assertTrue( have_posts() );
@ -136,7 +136,7 @@ EOF;
<p><span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.aulast=Mariat&amp;rft.aufirst=Denis&amp;rft. au=Denis+Mariat&amp;rft.au=Sead+Taourit&amp;rft.au=G%C3%A9rard+Gu%C3%A9rin&amp; rft.title=Genetics+Selection+Evolution&amp;rft.atitle=&amp;rft.date=2003&amp;rft. volume=35&amp;rft.issue=1&amp;rft.spage=119&amp;rft.epage=133&amp;rft.genre=article&amp; rft.id=info:DOI/10.1051%2Fgse%3A2002039"></span>Mariat, D., Taourit, S., Guérin, G. (2003). . <span style="font-style: italic">Genetics Selection Evolution, 35</span>(1), 119-133. DOI: <a rev="review" href="http://dx.doi.org/10.1051/gse:2002039">10.1051/gse:2002039</a></p>
EOF;
$post_id = $this->factory->post->create( compact( 'post_content' ) );
$post_id = self::$factory->post->create( compact( 'post_content' ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertTrue( is_single() );
$this->assertTrue( have_posts() );
@ -160,7 +160,7 @@ EOF;
<p><span title="My friends: Alice, Bob and Carol">foo</span></p>
EOF;
$post_id = $this->factory->post->create( compact( 'post_content' ) );
$post_id = self::$factory->post->create( compact( 'post_content' ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertTrue( is_single() );
$this->assertTrue( have_posts() );

View File

@ -11,9 +11,9 @@ class Tests_Post_Query extends WP_UnitTestCase {
function test_category__and_var() {
$q = new WP_Query();
$term_id = $this->factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
$term_id2 = $this->factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
$post_id = $this->factory->post->create();
$term_id = self::$factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
$term_id2 = self::$factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
$post_id = self::$factory->post->create();
wp_set_post_categories( $post_id, $term_id );
@ -41,8 +41,8 @@ class Tests_Post_Query extends WP_UnitTestCase {
* @group taxonomy
*/
function test_empty_category__in() {
$cat_id = $this->factory->category->create();
$post_id = $this->factory->post->create();
$cat_id = self::$factory->category->create();
$post_id = self::$factory->post->create();
wp_set_post_categories( $post_id, $cat_id );
$q1 = get_posts( array( 'category__in' => array( $cat_id ) ) );
@ -71,7 +71,7 @@ class Tests_Post_Query extends WP_UnitTestCase {
*/
function test_the_posts_filter() {
// Create posts and clear their caches.
$post_ids = $this->factory->post->create_many( 4 );
$post_ids = self::$factory->post->create_many( 4 );
foreach ( $post_ids as $post_id )
clean_post_cache( $post_id );
@ -115,19 +115,19 @@ class Tests_Post_Query extends WP_UnitTestCase {
}
function test_post__in_ordering() {
$post_id1 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$post_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$post_id3 = $this->factory->post->create( array(
$post_id1 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$post_id3 = self::$factory->post->create( array(
'post_type' => 'page',
'post_parent' => $post_id2,
'menu_order' => rand( 1, 100 )
) );
$post_id4 = $this->factory->post->create( array(
$post_id4 = self::$factory->post->create( array(
'post_type' => 'page',
'post_parent' => $post_id2,
'menu_order' => rand( 1, 100 )
) );
$post_id5 = $this->factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$post_id5 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
$ordered = array( $post_id2, $post_id4, $post_id3, $post_id1, $post_id5 );
@ -140,26 +140,26 @@ class Tests_Post_Query extends WP_UnitTestCase {
}
function test_post__in_attachment_ordering() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$att_ids = array();
$file = DIR_TESTDATA . '/images/canola.jpg';
$att_ids[1] = $this->factory->attachment->create_object( $file, $post_id, array(
$att_ids[1] = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 )
) );
$att_ids[2] = $this->factory->attachment->create_object( $file, $post_id, array(
$att_ids[2] = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 )
) );
$att_ids[3] = $this->factory->attachment->create_object( $file, $post_id, array(
$att_ids[3] = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 )
) );
$att_ids[4] = $this->factory->attachment->create_object( $file, $post_id, array(
$att_ids[4] = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 )
) );
$att_ids[5] = $this->factory->attachment->create_object( $file, $post_id, array(
$att_ids[5] = self::$factory->attachment->create_object( $file, $post_id, array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 )
) );
@ -311,10 +311,10 @@ class Tests_Post_Query extends WP_UnitTestCase {
public function test_post_name__in() {
$q = new WP_Query();
$post_ids[0] = $this->factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[1] = $this->factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[2] = $this->factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[3] = $this->factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[0] = self::$factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[1] = self::$factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[2] = self::$factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) );
$post_ids[3] = self::$factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) );
$requested = array( $post_ids[0], $post_ids[3] );
$q->query( array(

View File

@ -144,7 +144,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
* @ticket 16847
*/
function test_revision_view_caps_post() {
$post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
$revisions = wp_get_post_revisions( $post_id );
@ -166,7 +166,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
* @ticket 16847
*/
function test_revision_restore_caps_post() {
$post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
$revisions = wp_get_post_revisions( $post_id );
@ -186,7 +186,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
* @ticket 16847
*/
function test_revision_diff_caps_post() {
$post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) );
@ -214,7 +214,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
'supports' => array( 'revisions' ),
) );
$post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
$revisions = wp_get_post_revisions( $post_id );
@ -247,7 +247,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
$editor_user->add_cap( 'edit_published_events' );
//create a post as Editor
$post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
$revisions = wp_get_post_revisions( $post_id );
@ -282,7 +282,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
$old_id = get_current_user_id();
wp_set_current_user( self::$editor_user_id );
$post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) );
$post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
$revisions = wp_get_post_revisions( $post_id );
@ -314,7 +314,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
'supports' => array( 'revisions' ),
) );
$post_id = $this->factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
$post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) );
@ -337,7 +337,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
function test_wp_get_post_revisions_should_order_by_post_date() {
global $wpdb;
$post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
$post = (array) $post;
$post_revision_fields = _wp_post_revision_fields( $post );
@ -365,7 +365,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
* @ticket 26042
*/
function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() {
$post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
$post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
$post = (array) $post;
$post_revision_fields = _wp_post_revision_fields( $post );

View File

@ -8,7 +8,7 @@
class Tests_Post_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
$this->old_current_user = get_current_user_id();
wp_set_current_user( $this->author_id );
@ -33,7 +33,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase {
*
*/
function test_edit_post() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
$_POST = array();
$_POST['post_ID'] = $id;
@ -102,7 +102,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase {
*
*/
function test_wp_update_post() {
$id = $this->factory->post->create();
$id = self::$factory->post->create();
wp_update_post(array(
'ID' => $id,

View File

@ -8,7 +8,7 @@ class Tests_Post_Template extends WP_UnitTestCase {
function test_wp_link_pages() {
$contents = array( 'One', 'Two', 'Three' );
$content = join( '<!--nextpage-->', $contents );
$post_id = $this->factory->post->create( array( 'post_content' => $content ) );
$post_id = self::$factory->post->create( array( 'post_content' => $content ) );
$this->go_to( '?p=' . $post_id );
@ -81,15 +81,19 @@ class Tests_Post_Template extends WP_UnitTestCase {
$this->assertEmpty( $none );
$bump = '&nbsp;&nbsp;&nbsp;';
$page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$child_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) );
$grandchild_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$child_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) );
$grandchild_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) );
$title1 = get_post( $page_id )->post_title;
$title2 = get_post( $child_id )->post_title;
$title3 = get_post( $grandchild_id )->post_title;
$lineage =<<<LINEAGE
<select name='page_id' id='page_id'>
<option class="level-0" value="$page_id">Post title 1</option>
<option class="level-1" value="$child_id">{$bump}Post title 2</option>
<option class="level-2" value="$grandchild_id">{$bump}{$bump}Post title 3</option>
<option class="level-0" value="$page_id">$title1</option>
<option class="level-1" value="$child_id">{$bump}$title2</option>
<option class="level-2" value="$grandchild_id">{$bump}{$bump}$title3</option>
</select>
LINEAGE;
@ -99,7 +103,7 @@ LINEAGE;
$depth =<<<DEPTH
<select name='page_id' id='page_id'>
<option class="level-0" value="$page_id">Post title 1</option>
<option class="level-0" value="$page_id">$title1</option>
</select>
DEPTH;
@ -110,7 +114,7 @@ DEPTH;
$option_none =<<<NONE
<select name='page_id' id='page_id'>
<option value="Woo">Hoo</option>
<option class="level-0" value="$page_id">Post title 1</option>
<option class="level-0" value="$page_id">$title1</option>
</select>
NONE;
@ -124,7 +128,7 @@ NONE;
<select name='page_id' id='page_id'>
<option value="-1">Burrito</option>
<option value="Woo">Hoo</option>
<option class="level-0" value="$page_id">Post title 1</option>
<option class="level-0" value="$page_id">$title1</option>
</select>
NO;
@ -139,7 +143,7 @@ NO;
* @ticket 12494
*/
public function test_wp_dropdown_pages_value_field_should_default_to_ID() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
) );
@ -155,7 +159,7 @@ NO;
* @ticket 12494
*/
public function test_wp_dropdown_pages_value_field_ID() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
) );
@ -171,7 +175,7 @@ NO;
* @ticket 12494
*/
public function test_wp_dropdown_pages_value_field_post_name() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'foo',
) );
@ -188,7 +192,7 @@ NO;
* @ticket 12494
*/
public function test_wp_dropdown_pages_value_field_should_fall_back_on_ID_when_an_invalid_value_is_provided() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'foo',
) );
@ -205,7 +209,7 @@ NO;
* @ticket 30082
*/
public function test_wp_dropdown_pages_should_not_contain_class_attribute_when_no_class_is_passed() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'foo',
) );
@ -221,7 +225,7 @@ NO;
* @ticket 30082
*/
public function test_wp_dropdown_pages_should_obey_class_parameter() {
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'foo',
) );
@ -238,7 +242,7 @@ NO;
* @ticket 31389
*/
public function test_get_page_template_slug_by_id() {
$page_id = $this->factory->post->create( array(
$page_id = self::$factory->post->create( array(
'post_type' => 'page',
) );
@ -255,7 +259,7 @@ NO;
* @ticket 31389
*/
public function test_get_page_template_slug_from_loop() {
$page_id = $this->factory->post->create( array(
$page_id = self::$factory->post->create( array(
'post_type' => 'page',
) );
@ -269,7 +273,7 @@ NO;
* @ticket 31389
*/
public function test_get_page_template_slug_non_page() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_type' => 'post',
) );
@ -284,7 +288,7 @@ NO;
* @ticket 33974
*/
public function test_wp_page_menu_wp_nav_menu_fallback() {
$pages = $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) );
$pages = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
// No menus + wp_nav_menu() falls back to wp_page_menu().
$menu = wp_nav_menu( array( 'echo' => false ) );

View File

@ -8,7 +8,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
* @ticket 21013
*/
public function test_non_latin_slugs() {
$author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
$inputs = array(
'Αρνάκι άσπρο και παχύ της μάνας του καμάρι, και άλλα τραγούδια',
@ -49,9 +49,9 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
'post_name' => 'some-slug',
'post_status' => 'publish',
);
$one = $this->factory->post->create( $args );
$one = self::$factory->post->create( $args );
$args['post_type'] = 'post-type-2';
$two = $this->factory->post->create( $args );
$two = self::$factory->post->create( $args );
$this->assertEquals( 'some-slug', get_post( $one )->post_name );
$this->assertEquals( 'some-slug', get_post( $two )->post_name );
@ -74,9 +74,9 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
'post_name' => 'some-slug',
'post_status' => 'publish',
);
$one = $this->factory->post->create( $args );
$one = self::$factory->post->create( $args );
$args['post_name'] = 'some-slug-2';
$two = $this->factory->post->create( $args );
$two = self::$factory->post->create( $args );
$this->assertEquals( 'some-slug', get_post( $one )->post_name );
$this->assertEquals( 'some-slug-2', get_post( $two )->post_name );
@ -97,14 +97,14 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
'post_name' => 'some-slug',
'post_status' => 'publish',
);
$one = $this->factory->post->create( $args );
$one = self::$factory->post->create( $args );
$args = array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_name' => 'image'
);
$attachment = $this->factory->attachment->create_object( 'image.jpg', $one, $args );
$attachment = self::$factory->attachment->create_object( 'image.jpg', $one, $args );
$args = array(
'post_type' => 'post-type-1',
@ -112,7 +112,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
'post_status' => 'publish',
'post_parent' => $one
);
$two = $this->factory->post->create( $args );
$two = self::$factory->post->create( $args );
$this->assertEquals( 'some-slug', get_post( $one )->post_name );
$this->assertEquals( 'image', get_post( $attachment )->post_name );
@ -128,12 +128,12 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
* @dataProvider whitelist_post_statuses
*/
public function test_whitelisted_post_statuses_should_not_be_forced_to_be_unique( $status ) {
$p1 = $this->factory->post->create( array(
$p1 = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
$p2 = $this->factory->post->create( array(
$p2 = self::$factory->post->create( array(
'post_type' => 'post',
) );
@ -151,12 +151,12 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
}
public function test_revisions_should_not_be_forced_to_be_unique() {
$p1 = $this->factory->post->create( array(
$p1 = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
$p2 = $this->factory->post->create( array(
$p2 = self::$factory->post->create( array(
'post_type' => 'post',
) );
@ -171,7 +171,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() {
$this->set_permalink_structure( '/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -186,7 +186,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() {
$this->set_permalink_structure( '/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
'post_status' => 'publish',
@ -202,7 +202,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -217,7 +217,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -232,7 +232,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() {
$this->set_permalink_structure( '/%year%/foo/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -247,7 +247,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() {
$this->set_permalink_structure( '/%year%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -262,7 +262,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() {
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -277,7 +277,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );
@ -292,7 +292,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() {
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$p = $this->factory->post->create( array(
$p = self::$factory->post->create( array(
'post_type' => 'post',
'post_name' => 'foo',
) );

View File

@ -14,8 +14,8 @@ class Tests_Query extends WP_UnitTestCase {
*
*/
function test_nested_loop_reset_postdata() {
$post_id = $this->factory->post->create();
$nested_post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$nested_post_id = self::$factory->post->create();
$first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) );
while ( $first_query->have_posts() ) { $first_query->the_post();
@ -43,7 +43,7 @@ class Tests_Query extends WP_UnitTestCase {
* @ticket 25380
*/
function test_pre_posts_per_page() {
$this->factory->post->create_many( 10 );
self::$factory->post->create_many( 10 );
add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) );
@ -61,7 +61,7 @@ class Tests_Query extends WP_UnitTestCase {
*/
function test_tag_queried_object() {
$slug = 'tag-slug-26627';
$this->factory->tag->create( array( 'slug' => $slug ) );
self::$factory->tag->create( array( 'slug' => $slug ) );
$tag = get_term_by( 'slug', $slug, 'post_tag' );
add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
@ -94,11 +94,11 @@ class Tests_Query extends WP_UnitTestCase {
// Don't override the args provided below.
remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
register_taxonomy( 'wptests_tax', 'post' );
$terms = $this->factory->term->create_many( 2, array(
$terms = self::$factory->term->create_many( 2, array(
'taxonomy' => 'wptests_tax',
) );
$posts = $this->factory->post->create_many( 2 );
$posts = self::$factory->post->create_many( 2 );
wp_set_object_terms( $posts[0], array( $terms[0] ), 'wptests_tax' );
wp_set_object_terms( $posts[1], array( $terms[1] ), 'wptests_tax' );
@ -130,18 +130,18 @@ class Tests_Query extends WP_UnitTestCase {
}
public function test_cat_querystring_single_term() {
$c1 = $this->factory->category->create( array(
$c1 = self::$factory->category->create( array(
'name' => 'Test Category 1',
'slug' => 'test1',
) );
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'name' => 'Test Category 2',
'slug' => 'test2',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
wp_set_object_terms( $p1, $c1, 'category' );
wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
@ -159,23 +159,23 @@ class Tests_Query extends WP_UnitTestCase {
}
public function test_category_querystring_multiple_terms_comma_separated() {
$c1 = $this->factory->category->create( array(
$c1 = self::$factory->category->create( array(
'name' => 'Test Category 1',
'slug' => 'test1',
) );
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'name' => 'Test Category 2',
'slug' => 'test2',
) );
$c3 = $this->factory->category->create( array(
$c3 = self::$factory->category->create( array(
'name' => 'Test Category 3',
'slug' => 'test3',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, $c1, 'category' );
wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
@ -197,23 +197,23 @@ class Tests_Query extends WP_UnitTestCase {
* @ticket 33532
*/
public function test_category_querystring_multiple_terms_formatted_as_array() {
$c1 = $this->factory->category->create( array(
$c1 = self::$factory->category->create( array(
'name' => 'Test Category 1',
'slug' => 'test1',
) );
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'name' => 'Test Category 2',
'slug' => 'test2',
) );
$c3 = $this->factory->category->create( array(
$c3 = self::$factory->category->create( array(
'name' => 'Test Category 3',
'slug' => 'test3',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, $c1, 'category' );
wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
@ -233,18 +233,18 @@ class Tests_Query extends WP_UnitTestCase {
public function test_tag_querystring_single_term() {
$t1 = $this->factory->tag->create_and_get( array(
$t1 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 1',
'slug' => 'test1',
) );
$t2 = $this->factory->tag->create_and_get( array(
$t2 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 2',
'slug' => 'test2',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
wp_set_object_terms( $p1, $t1->slug, 'post_tag' );
wp_set_object_terms( $p2, array( $t1->slug, $t2->slug ), 'post_tag' );
@ -262,23 +262,23 @@ class Tests_Query extends WP_UnitTestCase {
}
public function test_tag_querystring_multiple_terms_comma_separated() {
$c1 = $this->factory->tag->create_and_get( array(
$c1 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 1',
'slug' => 'test1',
) );
$c2 = $this->factory->tag->create_and_get( array(
$c2 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 2',
'slug' => 'test2',
) );
$c3 = $this->factory->tag->create_and_get( array(
$c3 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 3',
'slug' => 'test3',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, $c1->slug, 'post_tag' );
wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' );
@ -300,23 +300,23 @@ class Tests_Query extends WP_UnitTestCase {
* @ticket 33532
*/
public function test_tag_querystring_multiple_terms_formatted_as_array() {
$c1 = $this->factory->tag->create_and_get( array(
$c1 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 1',
'slug' => 'test1',
) );
$c2 = $this->factory->tag->create_and_get( array(
$c2 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 2',
'slug' => 'test2',
) );
$c3 = $this->factory->tag->create_and_get( array(
$c3 = self::$factory->tag->create_and_get( array(
'name' => 'Test Tag 3',
'slug' => 'test3',
) );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, $c1->slug, 'post_tag' );
wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' );
@ -341,9 +341,9 @@ class Tests_Query extends WP_UnitTestCase {
wp_insert_term( 'test2', 'test_tax_cat' );
wp_insert_term( 'test3', 'test_tax_cat' );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
@ -365,10 +365,10 @@ class Tests_Query extends WP_UnitTestCase {
wp_insert_term( 'test2', 'test_tax_cat' );
wp_insert_term( 'test3', 'test_tax_cat' );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
@ -394,10 +394,10 @@ class Tests_Query extends WP_UnitTestCase {
wp_insert_term( 'test2', 'test_tax_cat' );
wp_insert_term( 'test3', 'test_tax_cat' );
$p1 = $this->factory->post->create();
$p2 = $this->factory->post->create();
$p3 = $this->factory->post->create();
$p4 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2 = self::$factory->post->create();
$p3 = self::$factory->post->create();
$p4 = self::$factory->post->create();
wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
@ -417,7 +417,7 @@ class Tests_Query extends WP_UnitTestCase {
* @ticket 31355
*/
public function test_pages_dont_404_when_queried_post_id_is_modified() {
$post_id = $this->factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) );
add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );
@ -438,7 +438,7 @@ class Tests_Query extends WP_UnitTestCase {
register_post_type( 'guide', array( 'name' => 'Guide', 'public' => true, 'hierarchical' => true ) );
$wp_rewrite->flush_rules();
$post_id = $this->factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) );
add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );

View File

@ -45,50 +45,50 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_permalink() {
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertQueryTrue('is_single', 'is_singular');
}
function test_post_comments_feed() {
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
$this->factory->comment->create_post_comments( $post_id, 2 );
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
self::$factory->comment->create_post_comments( $post_id, 2 );
$this->go_to( get_post_comments_feed_link( $post_id ) );
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
}
function test_post_comments_feed_with_no_comments() {
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
$this->go_to( get_post_comments_feed_link( $post_id ) );
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
}
function test_page() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
$this->go_to( get_permalink( $page_id ) );
$this->assertQueryTrue('is_page','is_singular');
}
function test_parent_page() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$this->go_to( get_permalink( $page_id ) );
$this->assertQueryTrue('is_page','is_singular');
}
function test_child_page_1() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$this->go_to( get_permalink( $page_id ) );
$this->assertQueryTrue('is_page','is_singular');
}
function test_child_page_2() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$this->go_to( get_permalink( $page_id ) );
$this->assertQueryTrue('is_page','is_singular');
@ -97,9 +97,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1'
function test_page_trackback() {
$page_ids = array();
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
foreach ( $page_ids as $page_id ) {
$url = get_permalink( $page_id );
$this->go_to("{$url}trackback/");
@ -116,11 +116,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
//'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
function test_page_feed() {
$page_ids = array();
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
foreach ( $page_ids as $page_id ) {
$this->factory->comment->create_post_comments( $page_id, 2 );
self::$factory->comment->create_post_comments( $page_id, 2 );
$url = get_permalink( $page_id );
$this->go_to("{$url}feed/");
@ -135,9 +135,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
function test_page_feed_with_no_comments() {
$page_ids = array();
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
foreach ( $page_ids as $page_id ) {
$url = get_permalink( $page_id );
$this->go_to("{$url}feed/");
@ -154,11 +154,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
function test_page_feed_atom() {
$page_ids = array();
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
foreach ( $page_ids as $page_id ) {
$this->factory->comment->create_post_comments( $page_id, 2 );
self::$factory->comment->create_post_comments( $page_id, 2 );
$url = get_permalink( $page_id );
$this->go_to("{$url}feed/atom/");
@ -174,7 +174,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
function test_page_page_2() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
$this->go_to("/about/page/2/");
// make sure the correct wp_query flags are set
@ -187,7 +187,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
function test_page_page_2_no_slash() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
$this->go_to("/about/page2/");
// make sure the correct wp_query flags are set
@ -201,7 +201,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// FIXME: what is this for?
// '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
function test_pagination_of_posts_page() {
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
update_option( 'show_on_front', 'page' );
update_option( 'page_for_posts', $page_id );
@ -223,7 +223,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
// '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
function test_main_feed_2() {
$this->factory->post->create(); // @test_404
self::$factory->post->create(); // @test_404
$feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom');
// long version
@ -241,7 +241,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_main_feed() {
$this->factory->post->create(); // @test_404
self::$factory->post->create(); // @test_404
$types = array('rss2', 'rss', 'atom');
foreach ($types as $type) {
$this->go_to(get_feed_link($type));
@ -252,7 +252,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
function test_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 5 );
self::$factory->post->create_many( 5 );
for ( $i = 2; $i <= 3; $i++ ) {
$this->go_to("/page/{$i}/");
$this->assertQueryTrue('is_home', 'is_paged');
@ -262,8 +262,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
// 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
function test_main_comments_feed() {
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
$this->factory->comment->create_post_comments( $post_id, 2 );
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
self::$factory->comment->create_post_comments( $post_id, 2 );
// check the url as generated by get_post_comments_feed_link()
$this->go_to( get_post_comments_feed_link( $post_id ) );
@ -306,7 +306,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
function test_search_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 3, array( 'post_title' => 'test' ) );
self::$factory->post->create_many( 3, array( 'post_title' => 'test' ) );
$this->go_to('/search/test/page/2/');
$this->assertQueryTrue('is_search', 'is_paged');
}
@ -328,7 +328,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
// 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
function test_category_feed() {
$this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -347,14 +347,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
function test_category_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 3 );
self::$factory->post->create_many( 3 );
$this->go_to('/category/uncategorized/page/2/');
$this->assertQueryTrue('is_archive', 'is_category', 'is_paged');
}
// 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
function test_category() {
$this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
$this->go_to('/category/cat-a/');
$this->assertQueryTrue('is_archive', 'is_category');
}
@ -362,7 +362,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
// 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
function test_tag_feed() {
$this->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
self::$factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -381,16 +381,16 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
function test_tag_paged() {
update_option( 'posts_per_page', 2 );
$post_ids = $this->factory->post->create_many( 3 );
$post_ids = self::$factory->post->create_many( 3 );
foreach ( $post_ids as $post_id )
$this->factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
self::$factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
$this->go_to('/tag/tag-a/page/2/');
$this->assertQueryTrue('is_archive', 'is_tag', 'is_paged');
}
// 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
function test_tag() {
$term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
$term_id = self::$factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
$this->go_to('/tag/tag-a/');
$this->assertQueryTrue('is_archive', 'is_tag');
@ -409,7 +409,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
// 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
function test_author_feed() {
$this->factory->user->create( array( 'user_login' => 'user-a' ) );
self::$factory->user->create( array( 'user_login' => 'user-a' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -428,22 +428,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
function test_author_paged() {
update_option( 'posts_per_page', 2 );
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
$this->factory->post->create_many( 3, array( 'post_author' => $user_id ) );
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
self::$factory->post->create_many( 3, array( 'post_author' => $user_id ) );
$this->go_to('/author/user-a/page/2/');
$this->assertQueryTrue('is_archive', 'is_author', 'is_paged');
}
// 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
function test_author() {
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
$this->factory->post->create( array( 'post_author' => $user_id ) );
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
self::$factory->post->create( array( 'post_author' => $user_id ) );
$this->go_to('/author/user-a/');
$this->assertQueryTrue('is_archive', 'is_author');
}
function test_author_with_no_posts() {
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
$this->go_to('/author/user-a/');
$this->assertQueryTrue('is_archive', 'is_author');
}
@ -451,7 +451,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
function test_ymd_feed() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -470,14 +470,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]',
function test_ymd_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/09/04/page/2/');
$this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged');
}
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
function test_ymd() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/09/04/');
$this->assertQueryTrue('is_archive', 'is_day', 'is_date');
}
@ -485,7 +485,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
// '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
function test_ym_feed() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -504,14 +504,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
function test_ym_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/09/page/2/');
$this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged');
}
// '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
function test_ym() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/09/');
$this->assertQueryTrue('is_archive', 'is_date', 'is_month');
}
@ -519,7 +519,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
// '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
function test_y_feed() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
// check the long form
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
foreach ($types as $type) {
@ -538,21 +538,21 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
function test_y_paged() {
update_option( 'posts_per_page', 2 );
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/page/2/');
$this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged');
}
// '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
function test_y() {
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
$this->go_to('/2007/');
$this->assertQueryTrue('is_archive', 'is_date', 'is_year');
}
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1',
function test_post_trackback() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$permalink = get_permalink( $post_id );
$this->go_to("{$permalink}trackback/");
$this->assertQueryTrue('is_single', 'is_singular', 'is_trackback');
@ -561,7 +561,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
function test_post_comment_feed() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$permalink = get_permalink( $post_id );
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
@ -580,7 +580,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]',
function test_post_paged_short() {
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_date' => '2007-09-04 00:00:00',
'post_title' => 'a-post-with-multiple-pages',
'post_content' => 'Page 1 <!--nextpage--> Page 2'
@ -593,7 +593,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
function test_post_attachment() {
$post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
$permalink = get_attachment_link( $post_id );
$this->go_to($permalink);
$this->assertQueryTrue('is_single', 'is_attachment', 'is_singular');
@ -629,8 +629,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
'public' => true
) );
$tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
$post_id = $this->factory->post->create( array( 'post_type' => $cpt_name ) );
$tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) );
$post_id = self::$factory->post->create( array( 'post_type' => $cpt_name ) );
wp_set_object_terms( $post_id, $tag_id, 'post_tag' );
$this->go_to( '/ptawtq/' );
@ -663,7 +663,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
'has_archive' => true,
'public' => true
) );
$this->factory->post->create( array( 'post_type' => $cpt_name ) );
self::$factory->post->create( array( 'post_type' => $cpt_name ) );
$this->go_to( "/$cpt_name/" );
$this->assertQueryTrue( 'is_post_type_archive', 'is_archive' );
@ -683,7 +683,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_is_single() {
$post_id = $this->factory->post->create();
$post_id = self::$factory->post->create();
$this->go_to( "/?p=$post_id" );
$post = get_queried_object();
@ -714,12 +714,12 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
) );
// Create parent and child posts
$parent_id = $this->factory->post->create( array(
$parent_id = self::$factory->post->create( array(
'post_type' => $post_type,
'post_name' => 'foo'
) );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_type' => $post_type,
'post_name' => 'bar',
'post_parent' => $parent_id
@ -750,10 +750,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_with_another_post_id() {
$p1 = $this->factory->post->create();
$p1 = self::$factory->post->create();
$p2_name = $p1 . '-post';
$p2 = $this->factory->post->create( array(
$p2 = self::$factory->post->create( array(
'slug' => $p2_name,
) );
@ -768,7 +768,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_is_page() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$this->go_to( "/?page_id=$post_id" );
$post = get_queried_object();
@ -788,11 +788,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 16802
*/
function test_is_page_with_parent() {
$parent_id = $this->factory->post->create( array(
$parent_id = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'foo',
) );
$post_id = $this->factory->post->create( array(
$post_id = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => 'bar',
'post_parent' => $parent_id,
@ -818,7 +818,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_is_attachment() {
$post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
$this->go_to( "/?attachment_id=$post_id" );
$post = get_queried_object();
@ -839,10 +839,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_attachment_with_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
$p1 = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
$p1 = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
$p2_name = $p1 . '-attachment';
$p2 = $this->factory->post->create( array(
$p2 = self::$factory->post->create( array(
'post_type' => 'attachment',
'post_name' => $p2_name,
) );
@ -861,10 +861,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() {
$u1 = $this->factory->user->create();
$u1 = self::$factory->user->create();
$u2_name = $u1 . '_user';
$u2 = $this->factory->user->create( array(
$u2 = self::$factory->user->create( array(
'user_nicename' => $u2_name,
) );
@ -882,10 +882,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_category_with_slug_that_begins_with_a_number_that_clashes_with_another_category_id() {
$c1 = $this->factory->category->create();
$c1 = self::$factory->category->create();
$c2_name = $c1 . '-category';
$c2 = $this->factory->category->create( array(
$c2 = self::$factory->category->create( array(
'slug' => $c2_name,
) );
@ -903,10 +903,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_tag_with_slug_that_begins_with_a_number_that_clashes_with_another_tag_id() {
$t1 = $this->factory->tag->create();
$t1 = self::$factory->tag->create();
$t2_name = $t1 . '-tag';
$t2 = $this->factory->tag->create( array(
$t2 = self::$factory->tag->create( array(
'slug' => $t2_name,
) );
@ -924,7 +924,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_page_with_page_id_zero_and_random_page_slug() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$this->go_to( "/?page_id=$post_id" );
// override post ID to 0 temporarily for testing
@ -946,10 +946,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_page_with_page_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
$p1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
$p1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
$p2_name = $p1 . '-page';
$p2 = $this->factory->post->create( array(
$p2 = self::$factory->post->create( array(
'post_type' => 'page',
'post_name' => $p2_name,
) );
@ -965,7 +965,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
}
function test_is_page_template() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
update_post_meta($post_id, '_wp_page_template', 'example.php');
$this->go_to( "/?page_id=$post_id" );
$this->assertTrue( is_page_template( 'example.php' ) );
@ -975,7 +975,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 31271
*/
function test_is_page_template_default() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
$this->go_to( "/?page_id=$post_id" );
$this->assertTrue( is_page_template( 'default' ) );
$this->assertTrue( is_page_template( array( 'random', 'default' ) ) );
@ -985,7 +985,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 31271
*/
function test_is_page_template_array() {
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
update_post_meta($post_id, '_wp_page_template', 'example.php');
$this->go_to( "/?page_id=$post_id" );
$this->assertFalse( is_page_template( array( 'test.php' ) ) );

Some files were not shown because too many files have changed in this diff Show More