mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
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:
@@ -22,7 +22,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase {
|
||||
function test_no_editable_posts() {
|
||||
$this->make_user_by_role( 'author' );
|
||||
$editor = $this->make_user_by_role( 'editor' );
|
||||
$this->factory->post->create( array( 'post_author' => $editor ) );
|
||||
self::$factory->post->create( array( 'post_author' => $editor ) );
|
||||
|
||||
$result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
@@ -32,7 +32,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase {
|
||||
function test_date() {
|
||||
$this->make_user_by_role( 'author' );
|
||||
|
||||
$this->factory->post->create();
|
||||
self::$factory->post->create();
|
||||
|
||||
$results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $results );
|
||||
|
||||
@@ -126,7 +126,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename, $post_id );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
|
||||
|
||||
// add post thumbnail to post that does not have one
|
||||
$post2 = array( 'wp_post_thumbnail' => $attachment_id );
|
||||
@@ -141,7 +141,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
|
||||
|
||||
// create another attachment
|
||||
$attachment2_id = $this->factory->attachment->create_upload_object( $filename, $post_id );
|
||||
$attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
|
||||
|
||||
// change the post's post_thumbnail
|
||||
$post4 = array( 'wp_post_thumbnail' => $attachment2_id );
|
||||
@@ -228,7 +228,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_author' => $editor_id
|
||||
) );
|
||||
|
||||
@@ -251,7 +251,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_empty_not_null() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Title',
|
||||
'post_author' => $editor_id,
|
||||
'tags_input' => 'taco'
|
||||
|
||||
@@ -95,7 +95,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename );
|
||||
|
||||
set_post_thumbnail( $this->post_id, $attachment_id );
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename, $this->post_id );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename, $this->post_id );
|
||||
set_post_thumbnail( $this->post_id, $attachment_id );
|
||||
|
||||
$results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) );
|
||||
|
||||
@@ -117,7 +117,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename );
|
||||
|
||||
$post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id );
|
||||
$result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
|
||||
|
||||
@@ -21,7 +21,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_incapable_user() {
|
||||
$this->make_user_by_role( 'subscriber' );
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) );
|
||||
$this->assertInstanceOf( 'IXR_Error', $result );
|
||||
@@ -30,7 +30,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_post_deleted() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
|
||||
@@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_author_can_edit_own_comment() {
|
||||
$author_id = $this->make_user_by_role( 'author' );
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post test by author',
|
||||
'post_author' => $author_id
|
||||
) );
|
||||
@@ -29,7 +29,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase {
|
||||
function test_author_cannot_edit_others_comment() {
|
||||
$this->make_user_by_role( 'author' );
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post test by editor',
|
||||
'post_author' => $editor_id
|
||||
) );
|
||||
@@ -49,7 +49,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_trash_comment() {
|
||||
$this->make_user_by_role( 'administrator' );
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
|
||||
$comment_data = array(
|
||||
'comment_post_ID' => $post_id,
|
||||
@@ -78,7 +78,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase {
|
||||
update_option( 'timezone_string', 'America/New_York' );
|
||||
|
||||
$this->make_user_by_role( 'administrator' );
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
|
||||
$comment_data = array(
|
||||
'comment_post_ID' => $post_id,
|
||||
|
||||
@@ -126,7 +126,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename, $post_id );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
|
||||
|
||||
// add post thumbnail to post that does not have one
|
||||
$post2 = array( 'post_thumbnail' => $attachment_id );
|
||||
@@ -148,7 +148,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
|
||||
|
||||
// create another attachment
|
||||
$attachment2_id = $this->factory->attachment->create_upload_object( $filename, $post_id );
|
||||
$attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
|
||||
|
||||
// change the post's post_thumbnail
|
||||
$post4 = array( 'post_thumbnail' => $attachment2_id );
|
||||
@@ -208,7 +208,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_capable_unsticky() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
stick_post( $post_id );
|
||||
|
||||
$post2 = array( 'sticky' => false );
|
||||
@@ -220,7 +220,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_password_transition_unsticky() {
|
||||
// when transitioning to private status or adding a post password, post should be un-stuck
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
$post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
stick_post( $post_id );
|
||||
|
||||
$post2 = array( 'post_password' => 'foobar', 'sticky' => false );
|
||||
@@ -234,7 +234,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
$yesterday = strtotime( '-1 day' );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post Revision Test',
|
||||
'post_content' => 'Not edited',
|
||||
'post_author' => $editor_id,
|
||||
@@ -263,7 +263,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_edit_attachment() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post Revision Test',
|
||||
'post_content' => 'Not edited',
|
||||
'post_status' => 'inherit',
|
||||
@@ -282,7 +282,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_use_invalid_post_status() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post Revision Test',
|
||||
'post_content' => 'Not edited',
|
||||
'post_author' => $editor_id,
|
||||
@@ -302,9 +302,9 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_loss_of_categories_on_edit() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$term_id = $this->factory->category->create();
|
||||
$this->factory->term->add_post_terms( $post_id, $term_id, 'category', true );
|
||||
$post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$term_id = self::$factory->category->create();
|
||||
self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
|
||||
$term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
|
||||
$this->assertContains( $term_id, $term_ids );
|
||||
|
||||
@@ -322,9 +322,9 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_clear_categories_on_edit() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$term_id = $this->factory->category->create();
|
||||
$this->factory->term->add_post_terms( $post_id, $term_id, 'category', true );
|
||||
$post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$term_id = self::$factory->category->create();
|
||||
self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
|
||||
$term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
|
||||
$this->assertContains( $term_id, $term_ids );
|
||||
|
||||
@@ -365,7 +365,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
// Add a dummy post
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Post Enclosure Test',
|
||||
'post_content' => 'Fake content',
|
||||
'post_author' => $editor_id,
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->post_id = $this->factory->post->create();
|
||||
$this->post_id = self::$factory->post->create();
|
||||
|
||||
$this->parent_comment_data = array(
|
||||
'comment_post_ID' => $this->post_id,
|
||||
|
||||
@@ -21,8 +21,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_capable_user() {
|
||||
$this->post_id = $this->factory->post->create();
|
||||
$this->factory->comment->create_post_comments( $this->post_id, 2 );
|
||||
$this->post_id = self::$factory->post->create();
|
||||
self::$factory->comment->create_post_comments( $this->post_id, 2 );
|
||||
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
@@ -36,8 +36,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_post_filter() {
|
||||
$this->post_id = $this->factory->post->create();
|
||||
$this->factory->comment->create_post_comments( $this->post_id, 2 );
|
||||
$this->post_id = self::$factory->post->create();
|
||||
self::$factory->comment->create_post_comments( $this->post_id, 2 );
|
||||
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
@@ -52,8 +52,8 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_number_filter() {
|
||||
$this->post_id = $this->factory->post->create();
|
||||
$this->factory->comment->create_post_comments( $this->post_id, 11 );
|
||||
$this->post_id = self::$factory->post->create();
|
||||
self::$factory->comment->create_post_comments( $this->post_id, 11 );
|
||||
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
@@ -76,13 +76,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
function test_contributor_capabilities() {
|
||||
$this->make_user_by_role( 'contributor' );
|
||||
$author_id = $this->make_user_by_role( 'author' );
|
||||
$author_post_id = $this->factory->post->create( array(
|
||||
$author_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Author',
|
||||
'post_author' => $author_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create( array(
|
||||
self::$factory->comment->create( array(
|
||||
'comment_post_ID' => $author_post_id,
|
||||
'comment_author' => "Commenter 1",
|
||||
'comment_author_url' => "http://example.com/1/",
|
||||
@@ -90,13 +90,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
) );
|
||||
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
$editor_post_id = $this->factory->post->create( array(
|
||||
$editor_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Editor',
|
||||
'post_author' => $editor_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create( array(
|
||||
self::$factory->comment->create( array(
|
||||
'comment_post_ID' => $editor_post_id,
|
||||
'comment_author' => 'Commenter 2',
|
||||
'comment_author_url' => 'http://example.com/2/',
|
||||
@@ -110,13 +110,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_author_capabilities() {
|
||||
$author_id = $this->make_user_by_role( 'author' );
|
||||
$author_post_id = $this->factory->post->create( array(
|
||||
$author_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Author',
|
||||
'post_author' => $author_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create( array(
|
||||
self::$factory->comment->create( array(
|
||||
'comment_post_ID' => $author_post_id,
|
||||
'comment_author' => 'Commenter 1',
|
||||
'comment_author_url' => 'http://example.com/1/',
|
||||
@@ -124,13 +124,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
) );
|
||||
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
$editor_post_id = $this->factory->post->create( array(
|
||||
$editor_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Editor',
|
||||
'post_author' => $editor_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create( array(
|
||||
self::$factory->comment->create( array(
|
||||
'comment_post_ID' => $editor_post_id,
|
||||
'comment_author' => 'Commenter 2',
|
||||
'comment_author_url' => 'http://example.com/2/',
|
||||
@@ -166,13 +166,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_editor_capabilities() {
|
||||
$author_id = $this->make_user_by_role( 'author' );
|
||||
$author_post_id = $this->factory->post->create( array(
|
||||
$author_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Author',
|
||||
'post_author' => $author_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create( array(
|
||||
self::$factory->comment->create( array(
|
||||
'comment_post_ID' => $author_post_id,
|
||||
'comment_author' => 'Commenter 1',
|
||||
'comment_author_url' => 'http://example.com/1/',
|
||||
@@ -180,13 +180,13 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
|
||||
));
|
||||
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
$editor_post_id = $this->factory->post->create( array(
|
||||
$editor_post_id = self::$factory->post->create( array(
|
||||
'post_title' => 'Editor',
|
||||
'post_author' => $editor_id,
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$this->factory->comment->create(array(
|
||||
self::$factory->comment->create(array(
|
||||
'comment_post_ID' => $editor_post_id,
|
||||
'comment_author' => 'Commenter 2',
|
||||
'comment_author_url' => 'http://example.com/2/',
|
||||
|
||||
@@ -122,8 +122,8 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase {
|
||||
function test_valid_page() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$parent_page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$child_page_id = $this->factory->post->create( array(
|
||||
$parent_page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$child_page_id = self::$factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $parent_page_id,
|
||||
'menu_order' => 2
|
||||
|
||||
@@ -54,7 +54,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
|
||||
$post_ids = array();
|
||||
$num_posts = 4;
|
||||
foreach ( range( 1, $num_posts ) as $i ) {
|
||||
$post_ids[] = $this->factory->post->create( array(
|
||||
$post_ids[] = self::$factory->post->create( array(
|
||||
'post_type' => $cpt_name,
|
||||
'post_date' => date( 'Y-m-d H:i:s', time() + $i )
|
||||
) );
|
||||
@@ -80,7 +80,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
|
||||
// add comments to some of the posts
|
||||
foreach ( $post_ids as $key => $post_id ) {
|
||||
// Larger post IDs will get more comments.
|
||||
$this->factory->comment->create_post_comments( $post_id, $key );
|
||||
self::$factory->comment->create_post_comments( $post_id, $key );
|
||||
}
|
||||
|
||||
// get results ordered by comment count
|
||||
@@ -109,7 +109,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
function test_fields() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
$this->factory->post->create();
|
||||
self::$factory->post->create();
|
||||
|
||||
// check default fields
|
||||
$results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
|
||||
@@ -136,8 +136,8 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
|
||||
function test_search() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_ids[] = $this->factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) );
|
||||
$post_ids[] = $this->factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) );
|
||||
$post_ids[] = self::$factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) );
|
||||
$post_ids[] = self::$factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) );
|
||||
|
||||
// Search for none of them
|
||||
$filter = array( 's' => rand_str() );
|
||||
|
||||
@@ -14,7 +14,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase {
|
||||
function test_incapable_user() {
|
||||
$this->make_user_by_role( 'subscriber' );
|
||||
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) );
|
||||
$this->assertInstanceOf( 'IXR_Error', $result );
|
||||
@@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase {
|
||||
function test_capable_user() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase {
|
||||
function test_revision_count() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
wp_insert_post( array( 'ID' => $post_id, 'post_content' => 'Edit 1' ) ); // Create the initial revision
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
||||
|
||||
@@ -106,8 +106,8 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase {
|
||||
$cat1 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
|
||||
$cat2 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
|
||||
|
||||
$this->factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) );
|
||||
$this->factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) );
|
||||
self::$factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) );
|
||||
|
||||
$filter = array( 'orderby' => 'count', 'order' => 'DESC' );
|
||||
$results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
|
||||
|
||||
@@ -79,7 +79,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase {
|
||||
if ( is_multisite() )
|
||||
grant_super_admin( $administrator_id );
|
||||
|
||||
$this->factory->user->create_many( 5 );
|
||||
self::$factory->user->create_many( 5 );
|
||||
|
||||
$user_ids = get_users( array( 'fields' => 'ID' ) );
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase {
|
||||
function test_new_comment_post_closed() {
|
||||
$this->make_user_by_role( 'administrator' );
|
||||
$post = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get( array(
|
||||
'comment_status' => 'closed'
|
||||
) );
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// create attachment
|
||||
$filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
|
||||
$attachment_id = $this->factory->attachment->create_upload_object( $filename );
|
||||
$attachment_id = self::$factory->attachment->create_upload_object( $filename );
|
||||
|
||||
$post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id );
|
||||
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
|
||||
|
||||
@@ -10,9 +10,9 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->post_id = $this->factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision
|
||||
$this->post_id = self::$factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision
|
||||
// First saved revision on update, see https://core.trac.wordpress.org/changeset/24650
|
||||
wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) );
|
||||
wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) );
|
||||
|
||||
$revisions = wp_get_post_revisions( $this->post_id );
|
||||
//$revision = array_shift( $revisions ); // First revision is empty - https://core.trac.wordpress.org/changeset/23842
|
||||
|
||||
Reference in New Issue
Block a user