From c067ef07ec4fd97cc0aa46d5c3cb85de51368309 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 13 Oct 2015 15:31:26 +0000 Subject: [PATCH] Create fewer fixtures in some XML-RPC tests. See #30017, #33968. git-svn-id: https://develop.svn.wordpress.org/trunk@35137 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/xmlrpc/wp/getPosts.php | 13 ++++++------- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index c15cdfb83c..0ea79e3f53 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -52,7 +52,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { )); $post_ids = array(); - $num_posts = 17; + $num_posts = 4; foreach ( range( 1, $num_posts ) as $i ) { $post_ids[] = $this->factory->post->create( array( 'post_type' => $cpt_name, @@ -67,7 +67,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // page through results $posts_found = array(); - $filter['number'] = 5; + $filter['number'] = 2; $filter['offset'] = 0; do { $presults = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); @@ -78,10 +78,9 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $this->assertEquals( 0, count( array_diff( $post_ids, $posts_found ) ) ); // add comments to some of the posts - $random_posts = array_rand( $post_ids, $num_posts / 2 ); - foreach ( $random_posts as $i ) { - $post = $post_ids[$i]; - $this->factory->comment->create_post_comments( $post, rand( 1, 20 ) ); + foreach ( $post_ids as $key => $post_id ) { + // Larger post IDs will get more comments. + $this->factory->comment->create_post_comments( $post_id, $key ); } // get results ordered by comment count @@ -96,7 +95,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { } // set one of the posts to draft and get drafts - $post = get_post( $post_ids[$random_posts[0]] ); + $post = get_post( $post_ids[0] ); $post->post_status = 'draft'; wp_update_post( $post ); $filter3 = array( 'post_type' => $cpt_name, 'post_status' => 'draft' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 546273eb48..7adacf190e 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -79,12 +79,12 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { if ( is_multisite() ) grant_super_admin( $administrator_id ); - $this->factory->user->create_many( 13 ); + $this->factory->user->create_many( 5 ); $user_ids = get_users( array( 'fields' => 'ID' ) ); $users_found = array(); - $page_size = floor( count( $user_ids ) / 3 ); + $page_size = 2; $filter = array( 'number' => $page_size, 'offset' => 0 ); do {